scope, namespace, variable, pagelayout, templates : how to ?

Author Message

Nicolas OTTAVI

Saturday 28 October 2006 4:05:14 am

Hi there,

In my pagelayout, I am defining a variable.

{def $myvar=''}
{set scope='global' $myvar='myvar'}

...

{$module_result.content}

The full/folder.tpl called when I view a folder in view full, contains this (it is an override templates of node/view/full.tpl)

<h3>{$#myvar}</h3>

The problem is that this doesn't work and do not display anything. I Don't know if it is a bug or a misunderstanding of the scope concept from myself.

Can someone help me and let me know how to retrieve a variable defined in pagelayout.tpl inside .tpl that are call from the {$module_result.content} ?

Thanks,
K.

Paul Borgermans

Saturday 28 October 2006 8:04:45 am

Hi Claude

That does not work because $module_result.content is generated before the pagelayout is processed. Hence your variable $myvar is simply not defined yet in your override for node/view/full.tpl The other way around should work though.

hth

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Nicolas OTTAVI

Wednesday 08 November 2006 2:10:36 am

Thanks for your answer Paul,

I did the stuff in a different way according to your answer. I've defined and set as global a variable in the template which override node/view/full.tpl.

Unfortunatly I can not access this global variable from the pagelayout.tpl. Any idea ?

Regards,
Claude

*- pike

Tuesday 26 June 2007 5:15:28 am

Same problem, no solution yet. EZP 3.7.6.

In the override template (that overrides node/view/full), I write

	{def $myvar=true()}
	{set scope='global' $myvar=true()}

In the pagelayout, I try

		test: {$myvar}
		#test: {$#myvar}

nothing ?

*-pike

---------------
The class eZContentObjectTreeNode does.

André R.

Tuesday 26 June 2007 5:27:14 am

use persistent variable to send stuff from content template to pagelayout!
http://issues.ez.no/IssueView.php?Id=10956&activeItem=44

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 30 2025 21:38:14
Script start
Timing: Jan 30 2025 21:38:14
Module start 'layout'
Timing: Jan 30 2025 21:38:14
Module start 'content'
Timing: Jan 30 2025 21:38:15
Module end 'content'
Timing: Jan 30 2025 21:38:15
Script end

Main resources:

Total runtime1.1867 sec
Peak memory usage8,192.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.3750151.2422
Module start 'layout' 0.00630.0036 739.6172220.7500
Module start 'content' 0.00991.1761 960.36724,548.3516
Module end 'content' 1.18600.0007 5,508.718811.7813
Script end 1.1867  5,520.5000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3097160.0002
Check MTime0.00130.1126160.0001
Mysql Total
Database connection0.00060.051210.0006
Mysqli_queries1.091191.9367670.0163
Looping result0.00070.0581650.0000
Template Total1.125394.820.5627
Template load0.00210.180620.0011
Template processing1.123294.642920.5616
Template load and register function0.00150.130310.0015
states
state_id_array0.00250.207710.0025
state_identifier_array0.00270.223920.0013
Override
Cache load0.00190.1578360.0001
Sytem overhead
Fetch class attribute can translate value0.00170.145840.0004
Fetch class attribute name0.00210.176370.0003
XML
Image XML parsing0.00130.107040.0003
class_abstraction
Instantiating content class attribute0.00000.001270.0000
General
dbfile0.00230.1939240.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs