how to retrieve all the attribute names and value in my template

Author Message

Alessandro Cipriani

Wednesday 04 August 2004 3:22:29 am

hi all
i have my template that matches all the objects of the class myclass.
in the template i'd like to fetch all the attributes of my class with their names in order to have a loop that writes:

attribute1
attribute1_value
attribute2
atribute2_value
ecc

in this way i will not need to modify my template if i'll need to add an attribute to my class, like already happens in the admin templates

any hint?

best regards
alessandro

Philip Redmon

Thursday 12 August 2004 9:01:03 am

Here are some code snips from my template. If I understand the question, you are displaying one object from the class? Or are you wanting to display a list of your objects, and display all the attributes of each object? Either way:

For showing attributes of specific objects:

{section name=ShowAttribute loop=$:item.contentobject_version_object.contentobject_attributes}
{attribute_view_gui attribute=$:item<br />
{$:item.contentclass_attribute.name|wash}
{/section}

For showing attributes for a list of objects

{let numberOfObjects=10}
{let collectionCount=fetch( 'content', 'list_count',
                         hash( 'parent_node_id', $node.node_id ) )}
{let collectionList=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id,
                                                 'sort_by', $node.sort_array,
                                                 'offset', $view_parameters.offset,
                                                 'limit', $numberOfObjects ) )}
<table width=100% border=1 bordercolor=#660000 cellpadding=10 cellspacing=0>

{* Loop through all the entries. *}
{section name=collectionLoop loop=$collectionList}

<tr><td>

{* grab and show all attributes for this object *}
{section name=ShowAttribute loop=$:item.contentobject_version_object.contentobject_attributes}
{attribute_view_gui attribute=$:item<br />
{$:item.contentclass_attribute.name|wash}
{/section}

</td></tr>

{* End of loop. *}
{/section}

</table>

{/let}
{/let}
{/let}

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 01:22:41
Script start
Timing: Jan 19 2025 01:22:41
Module start 'layout'
Timing: Jan 19 2025 01:22:41
Module start 'content'
Timing: Jan 19 2025 01:22:42
Module end 'content'
Timing: Jan 19 2025 01:22:42
Script end

Main resources:

Total runtime1.4989 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.0068 589.4453152.6563
Module start 'layout' 0.00680.0032 742.101639.4922
Module start 'content' 0.01001.4870 781.5938499.9063
Module end 'content' 1.49700.0019 1,281.50008.0938
Script end 1.4988  1,289.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2280160.0002
Check MTime0.00130.0898160.0001
Mysql Total
Database connection0.00130.083510.0013
Mysqli_queries1.448296.6174540.0268
Looping result0.00060.0402520.0000
Template Total1.454397.020.7272
Template load0.00200.131820.0010
Template processing1.452396.894220.7262
Template load and register function0.00010.006110.0001
states
state_id_array0.00210.142810.0021
state_identifier_array0.00200.136120.0010
Override
Cache load0.00160.1090220.0001
Sytem overhead
Fetch class attribute can translate value0.00080.050420.0004
Fetch class attribute name0.00210.138430.0007
XML
Image XML parsing0.00080.054020.0004
class_abstraction
Instantiating content class attribute0.00000.000530.0000
General
dbfile0.00100.0643160.0001
String conversion0.00000.000640.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
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.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/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/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: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs