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