Path

7x / documentation / ez publish / technical manual / 3.10 / reference / modules / content / fetch functions / collected_info_collection


Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

collected_info_collection

Summary

Fetches an information collection.

Usage

fetch( 'content', 'collected_info_collection',
       hash( 'collection_id',    collection_id,
             'contentobject_id', contentobject_id ) )

Parameters

NameTypeDescriptionRequired
collection_id integer The ID number of the collection that should be fetched. Yes.
contentobject_id integer The ID number of the object that should be fetched. Yes.

Returns

An ezinformationcollection object or FALSE.

Description

This function fetches an information collection. Both the ID number of the collection and the contentobject must be provided. The function returns an ezinformationcollection object or FALSE.

Examples

Example 1

{def $collection=fetch( 'content', 'collected_info_collection',
                        hash( 'collection_id',    123,
                              'contentobject_id', 456 ) )}
 
{foreach $collection.attributes as $attribute}
    {$attribute.contentclass_attribute_name} <br />
{/foreach}

Outputs the attributes for the 123rd information collection for object number 456.

Balazs Halasy (06/02/2004 12:04 pm)

Balazs Halasy (20/12/2005 11:39 am)


Comments

  • FYI: how to fetch all content collections for an obj

    The manual states that collection id is necessary, but if you omit it you will in fact fetch the last (first?) collection pertaining to the given obj.

    To fetch all collections in a single pass, to eg. display them in a frontend template, a loop must be used:

    {def $count=fetch( 'content', 'collected_info_count',
    hash( 'object_id', $node.contentobject_id ) )}
    {def $collection}
    {for 0 to $count as $collectionid}
    {set $collection=fetch( 'content', 'collected_info_collection',
    hash( 'object_id', $node.contentobject_id,
    'collection_id', $collectionid ) ) }
    {* admin might have deleted this collection! *}
    {if $collection}
    {section var=collectedAttributes loop=$collection.attributes}
    ...
    {section}
    {/if}
    {/for}