ez.no / exponential / documentation / development / libraries / ez template / operators / data fetch
These documentation pages are no longer maintained. Please visit the new documentation site.
Executes a given fetch operation, and returns the result. The parameters are the module name, the operation name,
and a hash of operation parameters corresponding to the given function_name in kernel/[module_name]/function_definition.php.
A few examples:
Fetch the number of items in a list:
{fetch('content','list_count',hash(parent_node_id,$node.node_id, sort_by,array(published,true()), class_filter_type,exclude, class_filter_array,array(1,24)))}
Fetch a class: Returns the content class defined by class_id. E.g.
{fetch('content','class',hash(class_id,4))}
Fetch a class attribute: Returns one specific class attribute defined by
attribute_id. The parameter version_id is optional (default 0) and
defines the version of the attribute. E.g.
{fetch('content','class_attribute',hash(attribute_id,140,version_id,0))}
Fetch a class attribute list: Returns an array of all attributes for one
class defined by class_id. The parameter version_id is optional
(default 0) and defines the version of the attributes. E.g.
{fetch('content','class_attribute_list',hash(class_id,4,version_id,0))}
As of version 3.2 Exponential supports sorting on attribute level. This means that you can sort a list of objects by any attribute that supports sorting ( not all datatypes can be sorted ).
Note: When doing attribute sorting Exponential will automatically filter on the class type.
Example of sorting on class attribute id 1 ( which can e.g. be title of the article class, the number to use as attribute id can be found when you view the definition of a content class ).
fetch('content', 'list', hash( parent_node_id, $node.node_id, sort_by,array(array('attribute',false(),1)), limit,$page_limit, offset, $view_parameters.offset ))
Note: In Exponential 3.2 ( rev 2868 ) you can filter the result on attribute values. The syntax for this is:
fetch( 'content', 'list', hash( parent_node_id, $node.node_id, attribute_filter, array( 'or', array( 152, '=', 'abc' ), array( 153, '=', '42' ) ) ) )
Where 152 and 153 are class attribute ID's. They are visible on class
edit. abc and 42 are the filter values. '=' is the filter type. Filter
types/operators currently implemented are:
= - equals != - not equals (requires 3.2-3, 3.3 or higher) < - less > - greater <= - less equal >= - greater equal
attribute_filter also support using class and class attribute identifiers.
fetch( 'content', 'list', hash( parent_node_id, $node.node_id, attribute_filter, array( array( 'article/title', '=', 'abc' ) ) ) )
Comments
Is it possible to fetch objects by creator, or by "can_edit"?
esu vytis
Sunday 10 April 2005 2:21:45 pm
Can't query by one attribute and sort by another.
Jason M
Wednesday 10 December 2003 8:46:35 pm
fetch(content, list, hash(parent_node_id, 55,depth, 3,offset, $view_parameters.offset, limit, 1,attribute_filter, array('and', array('183', '=' ,content_version.data_map.short_name.content)), sort_by,array(attribute,true(),185)))
and I keep ending up with no records. When reviewing the sql it appears that EZ is no capable of creating sql that queries one attribute and sorts by another.
Also look here...
Ben Pirt
Tuesday 09 September 2003 12:05:16 am
attribute_filter ..
Selmah Maxim
Saturday 19 July 2003 10:15:31 am
hash( parent_node_id, $node.node_id, attribute_filter,
array( 'or', array( 152, '=', 'abc' ),
array( 153, '=', '42' ) ) ) )
this query mean :
where 152='abc' or 153=42
??!
also can we use 'and' ?