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.

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 23:18:46
Script start
Timing: Jan 18 2025 23:18:46
Module start 'layout'
Timing: Jan 18 2025 23:18:46
Module start 'content'
Timing: Jan 18 2025 23:18:47
Module end 'content'
Timing: Jan 18 2025 23:18:47
Script end

Main resources:

Total runtime1.1812 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 589.2734152.6563
Module start 'layout' 0.00560.0034 741.929739.4922
Module start 'content' 0.00901.1705 781.4219511.6641
Module end 'content' 1.17940.0017 1,293.085912.1250
Script end 1.1811  1,305.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2798160.0002
Check MTime0.00140.1153160.0001
Mysql Total
Database connection0.00090.074010.0009
Mysqli_queries1.114194.3216660.0169
Looping result0.00060.0539640.0000
Template Total1.148297.220.5741
Template load0.00220.188320.0011
Template processing1.146097.020820.5730
Template load and register function0.00020.017310.0002
states
state_id_array0.00200.168210.0020
state_identifier_array0.00130.110620.0007
Override
Cache load0.00190.1614550.0000
Sytem overhead
Fetch class attribute can translate value0.00050.046320.0003
Fetch class attribute name0.00090.078760.0002
XML
Image XML parsing0.00020.020020.0001
class_abstraction
Instantiating content class attribute0.00000.000860.0000
General
dbfile0.00170.1407100.0002
String conversion0.00010.008740.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs