Forums / Developer / Trouble with redirect
Brendan Pike
Monday 02 June 2008 1:22:23 am
I'm trying to create a simple "add to notifications" button that changes to a "remove from notifications" button if the node_id already exists in the users notifications. AJAX would be the nicest method but that's beyond me. The actual adding / removing works fine with the below code but for it to be useful I'd really like to see it skip the "Notification was added successfully!" view and then on removal my RedirectURI doesn't get honoured and I get thrown to /notification/settings.
Does anyone have any ideas?
{if $module_result.node_id} {def $subscriptions=fetch( 'notification', 'subscribed_nodes' )} {if $subscriptions.[].node_id|contains($module_result.node_id)} <form method="post" action="/notification/settings"> <input type="hidden" name="SelectedRuleIDArray_ezsubtree[]" value="{$subscriptions.0.id}" /> <input type="hidden" name="RedirectURI" value={"content/view/full/2"|ezurl} /> <p><input class="button keep-me-updated" type="submit" name="RemoveRule_ezsubtree" value="Remove update for this section" /></p> </form> {else} <form method="post" action={'/content/action'|ezurl}> <input type="hidden" name="RedirectURI" value={"content/view/full/2"|ezurl} /> <input type="hidden" name="ContentNodeID" value="{$module_result.node_id}" /> <p><input class="button keep-me-updated" type="submit" name="ActionAddToNotification" value="Keep me updated on this section" /></p> </form> {/if} {/if}
www.dbinformatics.com.au We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.
Nathan Kelly
Monday 02 June 2008 1:33:54 am
Hi Brendan,
Looking at kernel/notification/settings it looks like action="notification/settings" uses "redirect_url" rather than "RedirectURI"
if ( $http->hasSessionVariable( "LastAccessesURI" ) ) $tpl->setVariable( 'redirect_url', $http->sessionVariable( "LastAccessesURI" ) );
Hope that helps
CheersNathan.
Pardon me while I burst into flames...
Monday 02 June 2008 1:43:15 am
Sorry,
after another look it seems there's no way to override the LastAccessURI within kernel/notification/settings, I'd say you'll either need to hack that file or use an extension for the redirect...
You could use the session variable extension to re-write the LastAccessURI for example...
http://ez.no/developer/contribs/template_plugins/template_session_functionalityhttp://ez.no/developer/contribs/template_plugins/smile_session
or maybe try...
http://ez.no/developer/contribs/template_plugins/redirect_operators
Just watch out if you are running eZ 4.0 you might need to update the extension for compatibility otherwise you may get some errors here and there...
Cheers.