Forums / Setup & design / How can I use the "IF command" in eZ Publish?

How can I use the "IF command" in eZ Publish?

Author Message

Leandro Alves

Wednesday 23 June 2004 10:11:27 am

Hi!!!

How can I use the "IF command" in eZ Publish 3.3-5? Is it possible?

I have the following structure:

Root Folder (node_id = 2)
|_Sales
...|_News (node_id = 10)
......|Folder1
........|Folder1a
......|Folder2
|_Account
...|_News (node_id = 20)
......|Folder1
......|Folder2
......|Folder3
|_Tech ((node_id = 30)

And I have this code to fetch and show the folders:

{let sub_menu=fetch(content,list,hash(parent_node_id,$node.node_id,
                                      sort_by, array( priority, true() ),
                                      class_filter_type, include,
                                      class_filter_array, array('folder')))}

{section name=item loop=$sub_menu}
  <ul>
   <li class="level_1">
     <a href={$:item.url_alias|ezurl}>{$:item.name|wash}</a>
   </li>
  <ul>
{/section}
{/let}

How you can see I am using the <b>$node.node_id</b> in the fetch command, so if I click in "Sales" or "Account" folders, all the folders into both will be listed, but if I click in "Sales/Folder1" only "Folder1a" will be listed and the "Sales", "Account" and "Tech" folders will disappear... I don't want this!!!

I want to fix the folders' node_id number in one level (Sales, Account, Tech)
Example:

<b>IF $node.node_id = 10</b>
<b>var_node = 10</b>

<b>IF $node.node_id = 20</b>
<b>var_node = 20</b>

<b>IF $node.node_id = 30</b>
<b>var_node = 30</b>

{let sub_menu=fetch(content,list,hash(parent_node_id, var_node,
                                      sort_by, array( priority, true() ),
                                      class_filter_type, include,
                                      class_filter_array, array('folder')))}

{section name=item loop=$sub_menu}
  <ul>
   <li class="level_1">
     <a href={$:item.url_alias|ezurl}>{$:item.name|wash}</a>
   </li>
  <ul>
{/section}
{/let}

Whith this, I am going to use the <b>var_node</b> in the fetch command...

So How Can I do it?
Is this the better method to do this?

Thanks!
Leandro

Alex Jones

Wednesday 23 June 2004 10:40:15 am

You can use the <i>{section-else} within your eZ code. Check out http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/functions/section You also have the option of using case statements: http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/functions/switch

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>