Forums / Setup & design / Usage of an if statement

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!

eZ debug

Timing: Jan 19 2025 07:25:18
Script start
Timing: Jan 19 2025 07:25:18
Module start 'content'
Timing: Jan 19 2025 07:25:18
Module end 'content'
Timing: Jan 19 2025 07:25:18
Script end

Main resources:

Total runtime0.1811 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 590.3828180.8359
Module start 'content' 0.00610.0062 771.218897.9922
Module end 'content' 0.01230.1687 869.2109523.7734
Script end 0.1810  1,392.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.8283200.0002
Check MTime0.00140.7511200.0001
Mysql Total
Database connection0.00070.385810.0007
Mysqli_queries0.128370.81411410.0009
Looping result0.00140.75721390.0000
Template Total0.168493.010.1684
Template load0.00090.488610.0009
Template processing0.167592.487410.1675
Override
Cache load0.00060.331310.0006
Sytem overhead
Fetch class attribute can translate value0.00060.309710.0006
XML
Image XML parsing0.00020.132410.0002
General
dbfile0.00874.7911200.0004
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs