Forums / Setup & design / Redirection and nested comments

Redirection and nested comments

Author Message

Pascal France

Sunday 02 September 2007 5:07:11 pm

Hi,

I configured nested comments, I mean that:

http://www.luxpopuli.fr/ez_publish__1/les_objets/ezcontentclass/objet_ezcontentclass_extraire_les_informations

All works fine, but I face a problem: How can I do in order the user is redirected to the article if he adds a n+1 (n gt 0) level comment ? Currently, the user is redirected to the n-1 level comment.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

André R.

Monday 03 September 2007 1:21:00 am

Try using this post variable: 'RedirectURIAfterPublish'

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pascal France

Monday 03 September 2007 1:56:45 am

Hi André,

Thanks for your answer. This is the good way ;-)

But I can't pass the node ID of the article to the edit/comment.tpl template.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

André R.

Monday 03 September 2007 1:59:48 am

You don't put it in you edit/*.tpl, you put it in the form that redirects it.
The from that surrounds the 'Add Comment' or 'New reply' buttons..

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pascal France

Monday 03 September 2007 2:47:20 am

I don't understand what you mean with "redirects it".

I use 4 templates

templates/full/aritcle/articles.tpl:

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input class="input_button" type="submit" name="NewButton" value=" " />
</form>

templates/line/comment.tpl (displays the first level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

templates/node/view/comment_fils.tpl (displays the n+1 level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

and the templates/edit/comment.tpl template to edit/write the comments.

Say the node ID of the article is 100.
If I add this line in the form section of the templates/edit/comment.tpl:

<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/100" />

then I'm well redirected to the article even I'm to the 10th level comment. But of course, 100 must be replace by something like {$article_node_id}.

In article.tpl I can define such a variable, but I don't know how to pass it to the edit/comment.tpl

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

André R.

Monday 03 September 2007 3:35:45 am

templates/full/aritcle/articles.tpl:

{def $my_article_id=$node.node_id}
<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value=" " />
</form>

templates/line/comment.tpl (displays the first level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$#my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

templates/node/view/comment_fils.tpl (displays the n+1 level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$#my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

# = global variable

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pascal France

Monday 03 September 2007 4:20:35 am

Thank you very much André !

All works prefectly.

Just an another little thing:

In the treemenu of the administration interface I noticed that once on two the comments are no more displayed and I have to refresh the treemenu in order they reappear.

Am I alone to notice this behavior ?

In contentstructuremenu.ini.append.php I have MaxNodes=950 and I have less than 950 nodes.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Tuesday 04 September 2007 5:00:26 am

Hi,

Following the explanations of André I founded the RedirectIfDiscarded variable and I add these lines:

templates/full/aritcle/articles.tpl:

{def $my_article_id=$node.node_id}
<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$my_article_id}" />
<input type="hidden" name="RedirectIfDiscarded" value="/content/view/full/{$my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value=" " />
</form>

templates/line/comment.tpl (displays the first level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$#my_article_id}" />
<input type="hidden" name="RedirectIfDiscarded" value="/content/view/full/{$#my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

templates/node/view/comment_fils.tpl (displays the n+1 level comments):

<form method="post" action={"content/action"|ezurl}>
<input type="hidden" name="ClassIdentifier" value="comment" />
<input type="hidden" name="NodeID" value="{$node.object.main_node.node_id}" />
<input type="hidden" name="ContentLanguageCode" value="{ezini( 'RegionalSettings', 'Locale', 'site.ini')}" />
<input type="hidden" name="RedirectURIAfterPublish" value="/content/view/full/{$#my_article_id}" />
<input type="hidden" name="RedirectIfDiscarded" value="/content/view/full/{$#my_article_id}" />
<input class="input_button" type="submit" name="NewButton" value="Ajouter un commentaire" />
</form>

But it doesn't work. The redirected URI is always the n-1 level comment (I cleared the caches)

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Tuesday 04 September 2007 5:19:58 am

I did a little test: in kernel/content/edit.php I changed these 2 lines:

578   if ( $http->hasPostVariable( 'RedirectIfDiscarded' ) )
579        $http->setSessionVariable( 'RedirectIfDiscarded', $http->postVariable( 'RedirectIfDiscarded' ) );

by these (since the RedirectURIAfterPublish Post variable is already defined in my templates and works fine):

578   if ( $http->hasPostVariable( 'RedirectURIAfterPublish' ) )
579        $http->setSessionVariable( 'RedirectURIAfterPublish', $http->postVariable( 'RedirectURIAfterPublish' ) );

But it doesn't work better.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

André R.

Tuesday 04 September 2007 5:54:09 am

The reason it dosn't work is that it has to be in kernel/content/action..

<form method="post" action={"content/action"|ezurl}>

You should add the lines the two places RedirectURIAfterPublish are used and make a enhencment issue for it in the issue tracker!

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Pascal France

Tuesday 04 September 2007 6:36:49 am

Thanks a lot again André ;-)

I had tried to add a line in content.php but only once (below line 127).

Now, with the second add (below line 183) the discard redirection works well.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

eZ debug

Timing: Jan 18 2025 04:29:01
Script start
Timing: Jan 18 2025 04:29:01
Module start 'content'
Timing: Jan 18 2025 04:29:01
Module end 'content'
Timing: Jan 18 2025 04:29:01
Script end

Main resources:

Total runtime0.1912 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0095 587.7266180.8359
Module start 'content' 0.00950.0108 768.5625117.9922
Module end 'content' 0.02030.1708 886.5547546.0547
Script end 0.1911  1,432.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00412.1225200.0002
Check MTime0.00150.7937200.0001
Mysql Total
Database connection0.00120.644810.0012
Mysqli_queries0.133069.57661410.0009
Looping result0.00140.75711390.0000
Template Total0.170289.010.1702
Template load0.00090.487410.0009
Template processing0.169388.539810.1693
Override
Cache load0.00060.327910.0006
Sytem overhead
Fetch class attribute can translate value0.00090.462910.0009
XML
Image XML parsing0.00030.170610.0003
General
dbfile0.00291.5260200.0001
String conversion0.00000.004630.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