Get last visited node

Author Message

Kévin S.

Friday 06 August 2010 3:17:27 am

Hello !
I have a form with an input that must be automatically filled when the page is loaded. To generate its value, I need to know the name of the node the user comes from.

Is it possible to get the previous node (the node which generated the page which called the current page) and how ?
Thank you !
___
Kévin

Romeo Antony

Friday 06 August 2010 5:51:45 am

Can you please explain more about it "I need to know the name of the node the user comes from. Is it possible to get the previous node (the node which generated the page which called the current page) and how ?"

Kévin S.

Friday 06 August 2010 6:02:44 am

Let's take an example : I am browsing my site. I'm currently viewing the page of the node named "A". Then, I click "submit" and I am redirected towards a form. The form has to know that I am coming from the "A" node, so it can auto-fill its input with "A"

In the form template, how can I do to get the previous node (in the example above, the previous node is the "A" node) ?.

Thiago Campos Viana

Friday 06 August 2010 7:18:54 am

You can create a cookie with this information when user is on node named "A" and then set the form input value reading and assigning cookie value to its value getting input element by id.

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Kévin S.

Friday 06 August 2010 7:48:07 am

A cookie could do it, you're right Thiago.

I'm actually looking for a way to do it within ez publish, if it exists.

Thiago Campos Viana

Friday 06 August 2010 10:02:30 am

You can create a template operator that sets and get a session value using ezhttptool: lib/ezutils/classes/ezhttptool.php

But it isn't as straightforward as using cookies.

Maybe {ezhttp( 'LastAccessesURI', 'session' )} could work, but you will need to fetch the node of the last access URI or something else, don't know, never tried.

Another way could be with $view_parameters, so you link your node b url as path_to_nodeB/(title)/NodeA Tiltle

Then in template you access node A name with {$view_parameters.title}

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Kévin S.

Friday 06 August 2010 3:00:20 pm

OK, thank you I will try that. I'll give you the feedback once it's done.

If anyone knows a simpler way to get the last visited node, I'm interested.

Kévin S.

Tuesday 10 August 2010 7:04:24 am

I've just finished using a HTTP GET parameter. Works like a charm, and does not need cookies or sessions.

I appended directly to the link URL the GET param (in the A node template) :

<a href={concat("bla/blabla/form?idselected=", $node.node_id)|ezurl}>my link</a>

Then in the form template, I used the ezhttp operator :

{if ezhttp_hasvariable( 'idselected', 'get' )}
    {def $idselected=ezhttp( 'idselected', 'get' )}
{/if}

Thank you for your help, Thiago !

___

Kévin

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