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

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 05:02:07
Script start
Timing: Jan 18 2025 05:02:07
Module start 'layout'
Timing: Jan 18 2025 05:02:07
Module start 'content'
Timing: Jan 18 2025 05:02:08
Module end 'content'
Timing: Jan 18 2025 05:02:08
Script end

Main resources:

Total runtime1.0356 sec
Peak memory usage4,096.0000 KB
Database Queries81

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 589.3438152.6250
Module start 'layout' 0.00760.0035 741.968839.4609
Module start 'content' 0.01101.0231 781.4297669.2266
Module end 'content' 1.03420.0014 1,450.656332.1641
Script end 1.0356  1,482.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3667160.0002
Check MTime0.00130.1270160.0001
Mysql Total
Database connection0.00120.114410.0012
Mysqli_queries0.933990.1718810.0115
Looping result0.00070.0680790.0000
Template Total0.991595.720.4957
Template load0.00220.211520.0011
Template processing0.989395.521320.4946
Template load and register function0.00030.024910.0003
states
state_id_array0.00110.103510.0011
state_identifier_array0.00110.104020.0005
Override
Cache load0.00210.1985810.0000
Sytem overhead
Fetch class attribute can translate value0.00100.094020.0005
Fetch class attribute name0.00110.1074120.0001
XML
Image XML parsing0.00060.061020.0003
class_abstraction
Instantiating content class attribute0.00000.0026150.0000
General
dbfile0.00750.7266170.0004
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
25content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 57
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs