Usage of an if statement

Author Message

Diederik Died

Thursday 31 July 2008 11:21:17 am

Hi,
I'm working on my first site with ezpublish, so this may come to you guys as a kind of newbie question, but we all got to learn right?

What i'm trying to make is an unsorted list with menu items witch are all part of one node. In Content structure I have a few folders, one of them is "Products" (node id 61), within that folder there are some subcategories, and under the subcategories there are the products themselfes.
I would like to construct an overview of all the subcategories and there products. I believe I can do it with the understanding code but it seems to lack the correct syntax in the if statement. (I know it should be and if, else statement but at least this is generating some results)
I do get a list with all my wanted elements, but the subcategories are treated as an product item. Can someone point me in the right direction? Such a simple thing is realy getting to me, been working this thing ofr a few hours now :-P So any help would realy be appreciated.

<ul>
{def $nodes=fetch( 'content', 'tree', 
                             hash( 'parent_node_id', 61 ) )}
{foreach $nodes as $node}
{def $nodes=fetch( 'content', 'tree', 
                             hash( 'parent_node_id', 61 ) )}


{ if $node:parent_node_id eq(61) }
           
             <li class="sub_category">{$node.item.name|wash}</li>
           
{/if}
           
           <li class="product_item"><a href={$node:item.url_alias|ezurl}>-{$node:item.parent_node_id}- {$node.name|wash} </a></li>

{/foreach}
</ul>

André R.

Thursday 31 July 2008 12:06:34 pm

<ul>
{def $nodes = fetch( 'content', 'tree', 
                            hash( 'parent_node_id', 61 ) )}

{foreach $nodes as $node}
{if $node.parent_node_id|eq(61)}
            <li class="sub_category">{$node.item.name|wash}</li>
{/if}
    <li class="product_item"><a href={$node.url_alias|ezurl}>-{$node.parent_node_id}- {$node.name|wash} </a></li>

{/foreach}
</ul>

I'm not quite sure what you're using the if and it's content for, can't make any sense of it, but at least this should be without your bugs, I guess you have copy pasted code from old code (witch probably used sequence operator, where it was more normal to use namespace, aka ":" aka $Nodes:item.something ).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Diederik Died

Monday 04 August 2008 12:01:27 pm

Thanks André! That indeed helped me on my way. Sorry if my explanations waren't clear of my purpose, but evenso you where able to push me in the right direction. Thanks again!

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 19 2025 06:25:19
Script start
Timing: Jan 19 2025 06:25:19
Module start 'layout'
Timing: Jan 19 2025 06:25:19
Module start 'content'
Timing: Jan 19 2025 06:25:20
Module end 'content'
Timing: Jan 19 2025 06:25:20
Script end

Main resources:

Total runtime0.7681 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.0071 589.1563152.6250
Module start 'layout' 0.00710.0058 741.781339.4453
Module start 'content' 0.01280.7540 781.2266542.2500
Module end 'content' 0.76690.0012 1,323.476612.1641
Script end 0.7681  1,335.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4449160.0002
Check MTime0.00150.1980160.0001
Mysql Total
Database connection0.00220.288610.0022
Mysqli_queries0.720593.7986570.0126
Looping result0.00080.0980550.0000
Template Total0.723594.220.3617
Template load0.00230.300120.0012
Template processing0.721193.882220.3606
Template load and register function0.00020.026710.0002
states
state_id_array0.00120.157910.0012
state_identifier_array0.00100.131420.0005
Override
Cache load0.00190.2469150.0001
Sytem overhead
Fetch class attribute can translate value0.00060.079320.0003
Fetch class attribute name0.00130.168140.0003
XML
Image XML parsing0.00070.091420.0004
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.00090.1117170.0001
String conversion0.00000.001340.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
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 14
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs