Global variable / Session variable

Author Message

B Pierre

Thursday 06 January 2011 2:43:37 am

Hi,

I need to pass on variable from pagelayout.tpl to all templates. I have something like this in top of pagelayout.tpl :

 If current_page type is X
    $var=current_page.valueA
 Else
    get $var

I tried to use global variable with

<u>to set value</u>
 {def $var="x"}
 {set scope="global" $var="x"}

<u>to get value</u>
 {$#var}

but this not running...

Any idea ?

And is it possible to make session variable with eZPublish ?

André R.

Thursday 06 January 2011 2:54:09 pm

1. remember that content views are executed before pagelayout.
2. if it is a content view then you can use $persistent_variable, if you'r using ezwebin then you can use ezpagedata_set / ezpagedata_append and it will work on any module / view.
3. yes, you can use session, it's available on the ezhttp function, but it's not the solution here I would say. And making use of sessions in presentation layer is a bit of a no no :)

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

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 11:30:54
Script start
Timing: Jan 18 2025 11:30:54
Module start 'layout'
Timing: Jan 18 2025 11:30:54
Module start 'content'
Timing: Jan 18 2025 11:30:55
Module end 'content'
Timing: Jan 18 2025 11:30:55
Script end

Main resources:

Total runtime0.6827 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 587.9219152.6250
Module start 'layout' 0.00640.0030 740.546939.4531
Module start 'content' 0.00940.6716 780.0000527.8594
Module end 'content' 0.68100.0016 1,307.85948.1563
Script end 0.6826  1,316.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4885160.0002
Check MTime0.00140.2069160.0001
Mysql Total
Database connection0.00120.170410.0012
Mysqli_queries0.637493.3677550.0116
Looping result0.00070.0956530.0000
Template Total0.653995.820.3270
Template load0.00220.316020.0011
Template processing0.651795.468720.3259
Template load and register function0.00020.025110.0002
states
state_id_array0.00070.099210.0007
state_identifier_array0.00080.114920.0004
Override
Cache load0.00170.2499170.0001
Sytem overhead
Fetch class attribute can translate value0.00160.232920.0008
Fetch class attribute name0.00150.225530.0005
XML
Image XML parsing0.00060.090220.0003
class_abstraction
Instantiating content class attribute0.00000.001230.0000
General
dbfile0.00150.2263170.0001
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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 13
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs