Forums / Developer / a variable witch is defind as integer becomes an array

a variable witch is defind as integer becomes an array

Author Message

Fox Mulder

Tuesday 18 September 2007 5:57:44 am

Hello
In the code down i can't understand how it is possible variable $last=0 witch has a value 0
to become an array with value few rows down {set lastlevel=$last.level} . In {set lastlevel=$last.level} variable last is already array and has value. How it happens?

Please help

$last=0
{*?template charset="utf-8"?*}

{def $depth=1 $last=0 $lastlevel=0 $x=1}
{def $mainMenu=treemenu( $module_result.path, $module_result.node_id,
, 0, 4)}
<ol>
{foreach $mainMenu as $menu}

{set lastlevel=$last.level}
{if and($lastlevel|ne(0), $lastlevel|gt($menu.level))}
</ol>
</li>
{set lastlevel=$lastlevel|sub(1)}
{/if}
<li>
{if and($last | ne(0), $last.level|lt($menu.level))}
<ol>
<li{$menu.is_selected|choose('',' class="selected"')}>
{/if}
<a {$menu.is_selected|choose('','class="selected"')}
href={$menu.url_alias|ezurl}>{$menu.text|shorten(25)}</a>
</li>

{set last=$menu}
{/foreach}

{while $depth |gt(1)}
</li>
</ol>
{set depth=$depth|sub(1)}
{/while}
</ol>

Laurent BOURREL

Tuesday 18 September 2007 6:53:38 am

Where did you find this code ?

Fox Mulder

Tuesday 18 September 2007 6:55:42 am

int the comment in this page http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/miscellaneous/treemenu

Laurent BOURREL

Tuesday 18 September 2007 8:43:34 am

OK, i didn't see one of the last line :
{set last=$menu}

At the first iteration, last is an integer, and for the next iterations, it becomes an array . That's why there's a test on the value and the level attribute.

Fox Mulder

Tuesday 18 September 2007 11:54:46 pm

Hmmm ...
I think that in first interation $lastlevel is empty and $last is zero so i don't understand how can be done $lastlevel|ne(0) when there is no value for $lastlevel.
i think it is some bug ...

Fox Mulder

Wednesday 19 September 2007 12:21:41 am

and one more thing ...
after first ineration $last becomes an array, so how it is possible to compare $last | ne(0)
(if an array not equal to zero).
So if there is someone who already have those answers, please tell us.

eZ debug

Timing: Jan 18 2025 21:03:35
Script start
Timing: Jan 18 2025 21:03:35
Module start 'content'
Timing: Jan 18 2025 21:03:35
Module end 'content'
Timing: Jan 18 2025 21:03:35
Script end

Main resources:

Total runtime0.0162 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.0703180.8125
Module start 'content' 0.00580.0050 769.882897.8203
Module end 'content' 0.01070.0054 867.703174.7031
Script end 0.0161  942.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002414.7216120.0002
Check MTime0.00116.5246120.0001
Mysql Total
Database connection0.00074.614710.0007
Mysqli_queries0.002313.923840.0006
Looping result0.00000.075220.0000
Template Total0.005031.110.0050
Template load0.00063.995310.0006
Template processing0.004427.074710.0044
Override
Cache load0.00042.659110.0004
General
dbfile0.00053.0824100.0000
String conversion0.00000.025130.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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