Forums / Developer / get objects for a specific class name

get objects for a specific class name

Author Message

Scott Foster

Saturday 25 December 2010 10:30:11 am

How can I get all the objects for a specific class based on the class identifier? I tried the following code for getting objects based on the class id -
// 72 being the ID for the standard_page class with 100 objects under it.
{let related_objects=fetch( 'content', 'related_objects', hash( 'object_id', 72 ) )}
{section loop=$related_objects var=related_object}
Name: {$related_object.item.name}<br />
{/section}
It returns nothing.
Any idea what I am doing wrong?

Peter Keung

Saturday 25 December 2010 10:27:24 pm

A few options:

Template code:
- content / list or content / tree fetch with class_filter_type "include" and class_filter_array with the class in question
- class / list fetch with class_filter with class in question, then access the undocumented .object_list attribute on the returned ezcontentclass object

PHP code:
- eZContentObject::fetchSameClassList( $contentClassID ) (http://pubsvn.ez.no/doxygen/4.4/html/classeZContentObject.html#ac330469c77b41c05170bd5cb2c770fb4)

http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada