Compare node class

Author Message

Alan Fowler

Thursday 07 April 2011 5:02:11 am

Hi,

I wish to put an if statement in my template that will only show if the node class is equal to that of a certain class. I'm using the code below to fetch the class name from the list of classes, but how do I compare it to the class of the node?

Many thanks for any help

Alan

{def $class=fetch('content', 'class', hash('class_id', 16))}

Marko Žmak

Thursday 07 April 2011 6:39:56 am

You should compare the identifier of the class with the class_identifier of $node.object (where we suppose your node is in the $node variable).

Or you could compare the class ID (16) with the contentclass_id.

See documentation for ezcontentobject and ezcontentclass:

  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Objects/ezcontentobject
  • http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Objects/ezcontentclass

and also try this in your template:

{$class|attribute(show)}
{$node.object|attribute(show)}

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

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 18 2025 01:11:09
Script start
Timing: Jan 18 2025 01:11:09
Module start 'layout'
Timing: Jan 18 2025 01:11:09
Module start 'content'
Timing: Jan 18 2025 01:11:10
Module end 'content'
Timing: Jan 18 2025 01:11:10
Script end

Main resources:

Total runtime1.0429 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.0078 589.0078152.6094
Module start 'layout' 0.00780.0043 741.617239.4219
Module start 'content' 0.01211.0282 781.0391527.8047
Module end 'content' 1.04040.0025 1,308.84388.1875
Script end 1.0428  1,317.0313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3503160.0002
Check MTime0.00140.1389160.0001
Mysql Total
Database connection0.00120.117410.0012
Mysqli_queries0.993595.2679540.0184
Looping result0.00060.0587520.0000
Template Total0.995595.520.4977
Template load0.00220.215420.0011
Template processing0.993295.239020.4966
Template load and register function0.00030.026310.0003
states
state_id_array0.00170.162010.0017
state_identifier_array0.00150.144520.0008
Override
Cache load0.00170.1636180.0001
Sytem overhead
Fetch class attribute can translate value0.00090.086320.0005
Fetch class attribute name0.00200.191330.0007
XML
Image XML parsing0.00070.071120.0004
class_abstraction
Instantiating content class attribute0.00000.001030.0000
General
dbfile0.00090.0856180.0000
String conversion0.00000.001240.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
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 11
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs