Forums / Setup & design / Is this a variable scope bug or just something I don't understand properly?

Is this a variable scope bug or just something I don't understand properly?

Author Message

Tristan Koen

Monday 11 August 2003 1:10:27 am

Hi All,

I have run into a very strange "bug" that I am at a loss to explain.

I have a {section name=Folder loop=...}. Within this section, I have access to a number of objects, including the 'item' object from the current iteration of the loop. For example, within the section I have a line:
<h1>{$Folder:item.name}</h1>
Which shows the name of the object. This works perfectly.
The problem comes in when I have a {let} or {section} embedded within the current {section} scope.
In any code following the embedded {/section}{/let} , I appear to lose all my objects - even though they remain in scope - EXCEPT for the LAST iteration of the loop which works.

The debug message I get is:
Unknown template variable 'item' in namespace 'Folder'

The offending line is the message below is:
<a href={concat('content/view/full/',$:item.node_id)|ezurl}>[ Read more about {$Folder:item.name}... ]</a>
</div>

If I move the offending line to a position before the embedded {let} it works as it should. Very odd...

Can anyone shed some light on this?

The full source code follows:

{let folder_list=fetch(content,list,hash(parent_node_id,47,
sort_by,array(array(priority))))}
{section name=Folder loop=$folder_list} ******** SECTION DECLARATION ********
<div class="columnItem">
<h1>{$Folder:item.name}</h1> ******** IN SCOPE; WORKS FINE ********
{let item_list=fetch(content,tree,hash(parent_node_id,$Folder:item.node_id,
class_filter_type,exclude,
class_filter_array,array(1),
sort_by,array(array(published,false()))))}
{section loop=$Folder:item_list}
<h2>{$:item.data_map.title.content}</h2>
{$:item.data_map.intro.content.output.output_text}
<p><a href={concat('content/view/full/',$:item.node_id)|ezurl}>[ Read More... ]</a></p>
{/section}
{/let}
<a href={concat('content/view/full/',$:item.node_id)|ezurl}>[ Read more about {$Folder:item.name}... ]</a> ******** SHOULD BE IN SCOPE. FAILS COMPLETELY EXCEPT FOR LAST ITERATION ********
</div>
{/section}
{/let}

Paul Borgermans

Monday 11 August 2003 10:17:06 am

I have had also variable scoping bugs with nested {section}{/section}

Definately something that needs to be checked. Or maybe I'll be wiser after the course next week and suffer from misunderstanding currently.

-paul

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

Tristan Koen

Tuesday 12 August 2003 1:26:20 am

Thanks for the confirmation Paul. I have filed a bug report.

eZ debug

Timing: Jan 18 2025 16:28:02
Script start
Timing: Jan 18 2025 16:28:02
Module start 'content'
Timing: Jan 18 2025 16:28:03
Module end 'content'
Timing: Jan 18 2025 16:28:03
Script end

Main resources:

Total runtime0.6899 sec
Peak memory usage4,096.0000 KB
Database Queries58

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.5234180.7813
Module start 'content' 0.00640.6773 770.3047549.2109
Module end 'content' 0.68370.0061 1,319.515646.3203
Script end 0.6898  1,365.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4543140.0002
Check MTime0.00140.1988140.0001
Mysql Total
Database connection0.00070.103810.0007
Mysqli_queries0.640792.8784580.0110
Looping result0.00060.0912560.0000
Template Total0.659595.620.3297
Template load0.00250.357020.0012
Template processing0.657095.233620.3285
Template load and register function0.00020.024610.0002
states
state_id_array0.00090.131310.0009
state_identifier_array0.00100.144620.0005
Override
Cache load0.00210.3018440.0000
Sytem overhead
Fetch class attribute can translate value0.00080.116120.0004
Fetch class attribute name0.00120.177940.0003
XML
Image XML parsing0.00050.074720.0003
class_abstraction
Instantiating content class attribute0.00000.001340.0000
General
dbfile0.00110.1545190.0001
String conversion0.00000.000930.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs