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.