Trouble with redirect

Author Message

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

Cheers
Nathan.

Pardon me while I burst into flames...

Nathan Kelly

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_functionality
http://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.

Pardon me while I burst into flames...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:05:44
Script start
Timing: Jan 18 2025 11:05:44
Module start 'layout'
Timing: Jan 18 2025 11:05:44
Module start 'content'
Timing: Jan 18 2025 11:05:44
Module end 'content'
Timing: Jan 18 2025 11:05:44
Script end

Main resources:

Total runtime0.0159 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.0078152.6094
Module start 'layout' 0.00590.0031 741.617239.4141
Module start 'content' 0.00900.0046 781.031393.4297
Module end 'content' 0.01370.0022 874.460934.3047
Script end 0.0158  908.7656 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002717.2618140.0002
Check MTime0.00117.0841140.0001
Mysql Total
Database connection0.00085.147310.0008
Mysqli_queries0.003119.405630.0010
Looping result0.00000.132010.0000
Template Total0.001811.510.0018
Template load0.00106.040010.0010
Template processing0.00095.385910.0009
Override
Cache load0.00074.422710.0007
General
dbfile0.00021.540780.0000
String conversion0.00000.049540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs