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.

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 19:02:12
Script start
Timing: Jan 18 2025 19:02:12
Module start 'layout'
Timing: Jan 18 2025 19:02:13
Module start 'content'
Timing: Jan 18 2025 19:02:13
Module end 'content'
Timing: Jan 18 2025 19:02:13
Script end

Main resources:

Total runtime0.0268 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.4063152.6875
Module start 'layout' 0.00530.0052 741.093839.5234
Module start 'content' 0.01050.0141 780.617289.4297
Module end 'content' 0.02460.0022 870.046934.3047
Script end 0.0268  904.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002810.4126140.0002
Check MTime0.00124.5689140.0001
Mysql Total
Database connection0.00083.152710.0008
Mysqli_queries0.004416.525830.0015
Looping result0.00000.067610.0000
Template Total0.00176.210.0017
Template load0.00093.484510.0009
Template processing0.00072.704310.0007
Override
Cache load0.00062.402810.0006
General
dbfile0.005922.066180.0007
String conversion0.00000.033840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs