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

list

Summary

Fetches a collection of classes.

Usage

fetch( 'class', 'list', hash( [ 'class_filter', class_filter ],
                              [ 'sort_by',      sort_by      ] ) )

Parameters

NameTypeDescriptionRequired
class_filter array The classes that should be filtered. No.
sort_by array The identifier of a desired class. No.

Returns

Array of ezcontentclass objects or FALSE.

Description

This function fetches a collection of classes. The optional "class_filter" parameter can be used to fetch only a given set of classes. This parameter must be either an array of class ID numbers or an array of class identifier strings (in other words: mixing is not possible). If the "class_filter" array is omitted, all classes will be returned.

The optional "sort_by" parameter makes it possible to sort the result in different ways. This parameter must be provided as an array. The first element of the array is the desired sorting method. The second element of the array is the sorting direction, it can be either true() or false() - ascending or descending. The following table shows the sorting methods that can be used.

Sorting method

Description

id

The classes are sorted by their ID numbers.

name

The classes are sorted by their names.

You can only use one sorting method per query. In other words, you can sort the classes by name or by ID, but not both in the same query.

Examples

Example 1

{def $classes=fetch( 'class', 'list' )}
 
{foreach $classes as $class}
    {$class.name|wash} <br />
{/foreach}

Outputs the names of all classes.

Example 2

{def $classes=fetch( 'class', 'list', hash( 'class_filter', array( 'folder', 'article' ) ) )}
 
{foreach $classes as $class}
    {$class.name|wash} <br />
{/foreach}

Outputs the names of the classes identified by the strings "folder" and "article".

Example 3

{def $classes=fetch( 'class', 'list',
                     hash( 'class_filter', array( 1, 2, 3 ),
                           'sort_by', array( 'name', true() ) ) )}

The function will fetch classes number 1, 2 and 3. The fetched classes will be sorted by name in ascending order.

Balazs Halasy (06/02/2004 11:54 am)

Julia Shymova (27/05/2008 10:27 am)

Balazs Halasy, Julia Shymova


Comments

There are no comments.