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.