Forums / Developer / Trouble with redirect

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...

eZ debug

Timing: Jan 30 2025 16:31:27
Script start
Timing: Jan 30 2025 16:31:27
Module start 'content'
Timing: Jan 30 2025 16:31:27
Module end 'content'
Timing: Jan 30 2025 16:31:27
Script end

Main resources:

Total runtime0.1978 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 587.8281370.3047
Module start 'content' 0.00720.0163 958.13281,005.6094
Module end 'content' 0.02360.1741 1,963.74223,895.9141
Script end 0.1977  5,859.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00502.5185200.0002
Check MTime0.00140.6915200.0001
Mysql Total
Database connection0.00080.384810.0008
Mysqli_queries0.093147.05451410.0007
Looping result0.00130.67561390.0000
Template Total0.173687.810.1736
Template load0.00070.360510.0007
Template processing0.172987.440310.1729
Override
Cache load0.00050.234110.0005
Sytem overhead
Fetch class attribute can translate value0.00211.073510.0021
XML
Image XML parsing0.00020.117310.0002
General
dbfile0.01266.3497200.0006
String conversion0.00000.002530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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