Forums / Setup & design / parent_class and is_container

parent_class and is_container

Author Message

Pascal France

Friday 18 August 2006 12:24:30 am

Hi,

I would like to define if the parent of a node is a folder, so, to to that I would like to define if this parent_node (or maybe parent_class) is a container.

Now, my code is:

{let enfant_1=fetch(content,list,hash(parent_node_id,$:item.node_id,
                    class_filter_type, "include",
                    class_filter_array, ezini( 'MenuContentSettingsMPT', 'TopIdentifierList', 'menu.ini' ) ,
                    sort_by,$base.sort_array))}
    <li>{* li_1 *}
        <a {section show=$enfant_1|count|gt(0)}{/section} href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a>

and I would like to include something like that:

    <li>{* li_1 *}
        {if eq(<parent_node or parent_class>.is_container, true())}
            something here
        {else}
        <a {section show=$child_check|count|gt(0)}{/section} href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a>
        {/if}

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Friday 18 August 2006 8:16:58 am

Hi,

Well... I'm looking for another solution with the class identifier.
The initial code is:

{section loop=fetch(content,list,hash(parent_node_id,$top_cat,
                class_filter_type, "include",
                class_filter_array, ezini( 'MenuContentSettingsMPT', 'TopIdentifierList', 'menu.ini' ) ,
                sort_by,$base.sort_array))}
{let child_check=fetch(content,list,hash(parent_node_id,$:item.node_id,
                    class_filter_type, "include",
                    class_filter_array, ezini( 'MenuContentSettingsMPT', 'TopIdentifierList', 'menu.ini' ) ,
                    sort_by,$base.sort_array))}
    <li>{* li_1 *}
        <a {section show=$child_check|count|gt(0)}{/section} href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a>

I want that if $child_check class is a folder class, then it won't be a link.

So, I begin to find the class identifier of $child_check

    <li>{* li_1 *}
        {def $aaa1=$:item.object.class_identifier}

...and this works fine.
According with the "is_class" doc I have tried:

    <li>{* li_1 *}
        {def $aaa1=$:item.object.class_identifier}
        {section show=$child_check|count|gt(0)}{/section}
        {if is_class('dossier_assemblee_generale', $aaa1)}
            {$:item.name}
        {else}
        <a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl}>{$:item.name}</a>
        {/if}

But this doesn't work.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Claudia Kosny

Friday 18 August 2006 12:05:10 pm

Hello Pascal,

Unfortunately I am not exactly sure what exactly you try to do, therefore some code examples below which hopefully help you further.

First a remark to your code though:
You use

 {section show=$child_check|count|gt(0)}{/section}

Both in your first and in your second example. But this will not do anything at all as you have no code between the opening anf the closing of the section. The usage for section show is roughly like this:

{section show=<some condition here>}
 this code is only executed when the condition in show is true
{section-else}
this code is only executed when the condition in show is false
{/section}

(The else part is not required)

If the code samples below do not help you please post again but this time without any code. Just explain in short sentences what exaxtly try to achieve.

Here my examples. Please check the comments at each foreach loop as this explains, what exactly we are checking for. Also you have to adapt the fetch function in the beginning to yours.

{* fetch the main nodes *}
{def $main_nodes = fetch(content,tree,hash(parent_node_id,2))}

{* check whether any of these nodes is a container *}
{foreach $main_nodes as $main_node}
 {if $main_node.object.content_class.is_container}
  {$main_node.name} is a container <br />
 {else}
  {$main_node.name} is NOT a container <br />
 {/if}
{/foreach}
<br />
<br />

{* check whether any of these nodes contains any child nodes *}
{foreach $main_nodes as $main_node}
 {if $main_node.children_count|gt(0)}
  {$main_node.name} is a container <br />
 {else}
  {$main_node.name} is either not a container or is a container that has no children at the moment<br />
 {/if}
{/foreach}
<br />
<br />

{* check whether any of these nodes has a class identifier defined in 
   array $folderClasses, this array can also come from an ini file *}
{def $folderClasses = array('folder', 'specialfolder')}
{foreach $main_nodes as $main_node}
 {if $folderClasses|contains($main_node.class_identifier)}
  {$main_node.name} is a folderclass <br />
 {else}
  {$main_node.name} is NOT a folderclass <br />
 {/if}
{/foreach}
<br />
<br />

{* check whether the parent node of any one of these nodes has a 
  class identifier defined in array $folderClasses *}
{* we KNOW that the parentnode is a container as otherwise it could
   not contain children but maybe we want to check for somehting  else *}
{foreach $main_nodes as $main_node}
 {if $folderClasses|contains($main_node.parent.class_identifier)}
  the parent of {$main_node.name} is a folderclass <br />
 {else}
  the parent of {$main_node.name} is NOT a folderclass <br />
 {/if}
{/foreach}

Greetings from Luxembourg

Claudia

Pascal France

Sunday 20 August 2006 1:00:19 am

Hi Claudia,

Thank you very much !

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

eZ debug

Timing: Jan 19 2025 01:21:38
Script start
Timing: Jan 19 2025 01:21:38
Module start 'content'
Timing: Jan 19 2025 01:21:38
Module end 'content'
Timing: Jan 19 2025 01:21:38
Script end

Main resources:

Total runtime0.1538 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.0078 588.9531180.8359
Module start 'content' 0.00780.0059 769.789197.8828
Module end 'content' 0.01370.1400 867.6719527.0547
Script end 0.1537  1,394.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00352.3047200.0002
Check MTime0.00140.9334200.0001
Mysql Total
Database connection0.00070.473310.0007
Mysqli_queries0.108670.64201410.0008
Looping result0.00130.86971390.0000
Template Total0.139590.710.1395
Template load0.00100.629410.0010
Template processing0.138590.079810.1385
Override
Cache load0.00070.457010.0007
Sytem overhead
Fetch class attribute can translate value0.00080.535210.0008
XML
Image XML parsing0.00020.136610.0002
General
dbfile0.00312.0445200.0002
String conversion0.00000.004030.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