ibexa

Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

fetch_alias

Summary

Executes a fetch based on configuration settings.

Usage

fetch_alias( alias_name, hash( [ parameter1, value1, ]
                               [ parameter2, value2  ] ) )

Parameters

NameTypeDescriptionRequired
alias_name string The name of the fetch alias that should be used. Yes.
parameter1 string The name of parameter 1. No.
value1 string The value of parameter 1. No.
parameter2 string The name of parameter2. No.
value2 string The value of parameter 2. No.

Description

This function can be thought of as a configuration-file based version of the "fetch" operator. It makes it possible to move data fetching blocks from template code to a configuration file and thus gather all fetches at one place. The advantage of such a scenario is that it allows quick modifications without the need of having to locate and modify different templates. The fetch aliases must be defined in a configuration override for "fetchalias.ini". Each fetch has to be defined within its own block with a unique name. The following code shows the basic syntax/structure of a fetch block.

[fetch_alias_name]
Module=module_name
FunctionName=function_name
Parameter[parameter1]=fetch_alias_name1
Parameter[parameter2]=fetch_alias_name2
...
Constant[parameter3]=<any value>
Constant[parameter4]=<any value>
...

Directive

Description

Module

The name of the target module (for example "content").

FunctionName

The name of the target fetch function (for example "list").

Parameter

The "Parameters" array may be used to specify variables that will be set in the template(s). The "parameter_name" maps to the parameter name used in normal fetch functions. The "fetch_alias_name" will be the parameter name used in the template(s).

Constant

Parameters that are defined as constants within the regular fetch function(s).

Examples

Example 1

Configuration block:

[object]
Module=content
FunctionName=object
Parameter[object_id]=id

Template code:

{def $object=fetch_alias( 'object', hash( 'id', 1 ) )}

This example demonstrates how to fetch an object.

Example 2

Configuration block:

[comments]
Module=content
FunctionName=list
Constant[sort_by]=published;0
Parameter[parent_node_id]=parent_node_id
Constant[class_filter_type]=include
Constant[class_filter_array]=comment

Template code:

{def $comments=fetch_alias( 'comments', hash( 'parent_node_id', 42 ) )}

This example demonstrates how to fetch comments.

Example 3

Configuration block:

[news_list]
Module=content
FunctionName=tree
Constant[sort_by]=published;0
Constant[class_id]=2
Constant[parent_node_id]=2
Constant[class_filter_type]=include
Constant[limit]=10
Constant[class_filter_array]=2

Template code:

{foreach fetch_alias( 'news_list' ) as $article}
    {node_view_gui node=$article}
{/foreach}

This example demonstrates how to fetch and display the 10 latest news articles using full view.

Balazs Halasy (19/07/2004 10:11 am)

Balazs Halasy (28/04/2005 1:54 pm)


Comments

  • fetch documentation

    where is "fetch" documentation ?