Please help assigning value to a variable - not working properly

Author Message

jonathan howes

Thursday 01 May 2003 2:49:22 pm

I am using the code below in a template. the purpose is to only display certain folders based on the partent folder at the root level. At the root level each parent folder is in a unique section.

I am going out and getting all section and node values for the content of node_id=2 and comparing to the section id of the page that is currently displayed ( So if you are viewing a folder 4 levels deep (node_id=287 section_id=3) the script will return the node_id (node_id=234 and section_id =3) of the 1st level folder in that section at the content level node_id=2.

Whilst viewing a page with a node_id=287 the script sets the variable top_cat =24 (default incase of a folder not assigned to a cestion or some other error) then goes out and returns the node_id of the root parent which is 234 (this value is correct and then should assign this value to top_cat. It then displays the current value of top_cat.

The out put I am getting is
!24!
[234]
=24=
*24*

The output I expected is
!24!
[234]
=234=
*234*

the problem seems to be in the assignment of the {set top_cat=....}

Can Anyone help me please - I have tried everything I can think of

jonathan

<tr>

<td class="menuitem">
{* Set your top category here *}
{let top_cat=24
used_node=false()
menu_css=5
menu_css_active=6}
!{$top_cat}!
{let name=Child children=fetch('content','list',hash(parent_node_id,2))}
{section loop=$:children}
{section show=eq($Child:item.object.section_id,$DesignKeys:used.section)}
{set top_cat=$Child:item.node_id}
[ {$Child:item.node_id} ]
= {$top_cat} =
{/section}
{/section}
{/let}
{* Set your top category here *}
*{$top_cat}*
{/let}
</td>
</tr>

Vivienne van Velzen

Friday 02 May 2003 2:52:20 am

Jonathan,

Can't really explain why, but the problem lies with the fact that you name the second {let}. I changed your code to the following, and that works.

{let top_cat=24
used_node=false()
menu_css=5
menu_css_active=6}
!{$top_cat}!
{let children=fetch('content','list',hash(parent_node_id,2))}
{section loop=$:children}
{section show=eq($:item.object.section_id,$DesignKeys:used.section)}
{set top_cat=$:item.node_id}
[ {$:item.node_id} ]
= {$top_cat} =
{/section}
{/section}
{/let}
{* Set your top category here *}
*{$top_cat}*
{/let}

As you can see, I removed the name 'Child' from the second {let} and the loop items (you could even remove the whole second let and place the fetch in the section, i.e. loop=fetch(...)).
Anyway, as said, the above works for me. Now I'm gonna look a bit closer at namespaces.....
Greetz,

Vivienne

jonathan howes

Friday 02 May 2003 4:34:56 am

Thanks for the help - I had about 10 different verions of the same coded - all with minor differences - all returned the same problem in terms of not setting the value.

Thanks for the info on the {section=name loop=fetch()} I have use it before but I felt my above example was the clearest in terms of "full" code with no short cuts.

Maybe someone at ez publish or one of the other members of this forum can explain the problem in my original code and post some more info about the namespaces.

Jonathan

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

Main resources:

Total runtime0.9438 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0089 588.1719152.6563
Module start 'layout' 0.00890.0039 740.828139.5234
Module start 'content' 0.01280.9294 780.3516483.8359
Module end 'content' 0.94220.0015 1,264.187512.0938
Script end 0.9437  1,276.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3627160.0002
Check MTime0.00140.1497160.0001
Mysql Total
Database connection0.00110.120210.0011
Mysqli_queries0.877592.9712570.0154
Looping result0.00060.0642550.0000
Template Total0.906496.020.4532
Template load0.00220.230020.0011
Template processing0.904295.801220.4521
Template load and register function0.00020.023410.0002
states
state_id_array0.00110.113110.0011
state_identifier_array0.00370.395120.0019
Override
Cache load0.00180.1934700.0000
Sytem overhead
Fetch class attribute can translate value0.00070.072220.0003
Fetch class attribute name0.00220.235430.0007
XML
Image XML parsing0.00040.041920.0002
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00170.1789100.0002
String conversion0.00000.001240.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
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs