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>

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 11:40:47
Script start
Timing: Jan 19 2025 11:40:47
Module start 'layout'
Timing: Jan 19 2025 11:40:47
Module start 'content'
Timing: Jan 19 2025 11:40:48
Module end 'content'
Timing: Jan 19 2025 11:40:48
Script end

Main resources:

Total runtime1.5843 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 589.2891152.6406
Module start 'layout' 0.00940.0051 741.929739.4766
Module start 'content' 0.01441.5682 781.4063537.1797
Module end 'content' 1.58270.0015 1,318.585912.1250
Script end 1.5842  1,330.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2077160.0002
Check MTime0.00130.0845160.0001
Mysql Total
Database connection0.00130.081610.0013
Mysqli_queries1.527396.4027540.0283
Looping result0.00060.0371520.0000
Template Total1.529596.520.7647
Template load0.00220.136020.0011
Template processing1.527396.405920.7637
Template load and register function0.00020.013910.0002
states
state_id_array0.00170.108610.0017
state_identifier_array0.00310.196020.0016
Override
Cache load0.00180.1167390.0000
Sytem overhead
Fetch class attribute can translate value0.00070.043220.0003
Fetch class attribute name0.00150.094430.0005
XML
Image XML parsing0.00090.054120.0004
class_abstraction
Instantiating content class attribute0.00000.000530.0000
General
dbfile0.00340.2165160.0002
String conversion0.00000.000740.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.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: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs