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.

eZ debug

Timing: Jan 18 2025 02:45:27
Script start
Timing: Jan 18 2025 02:45:27
Module start 'layout'
Timing: Jan 18 2025 02:45:27
Module start 'content'
Timing: Jan 18 2025 02:45:28
Module end 'content'
Timing: Jan 18 2025 02:45:28
Script end

Main resources:

Total runtime1.2925 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 591.4453152.6094
Module start 'layout' 0.00570.0035 744.054739.4141
Module start 'content' 0.00921.2816 783.4688636.4141
Module end 'content' 1.29080.0016 1,419.882816.1875
Script end 1.2925  1,436.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2517160.0002
Check MTime0.00140.1048160.0001
Mysql Total
Database connection0.00070.056010.0007
Mysqli_queries1.228795.0647740.0166
Looping result0.00070.0521720.0000
Template Total1.254097.020.6270
Template load0.00200.158020.0010
Template processing1.252096.862620.6260
Template load and register function0.00030.020310.0003
states
state_id_array0.00110.084310.0011
state_identifier_array0.00240.185520.0012
Override
Cache load0.00180.1356420.0000
Sytem overhead
Fetch class attribute can translate value0.00070.051530.0002
Fetch class attribute name0.00140.1085100.0001
XML
Image XML parsing0.00130.097530.0004
class_abstraction
Instantiating content class attribute0.00000.0017110.0000
General
dbfile0.00130.1023220.0001
String conversion0.00000.000740.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
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
12content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
2content/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: 30
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs