fetch( 'content', 'keyword', hash( 'alphabet', alphabet, [ 'classid', classid, ] [ 'limit', limit, ] [ 'offset', offset, ] [ 'owner', owner, ] [ 'sort_by', sort_by, ] ) )
Name | Type | Description | Required |
---|---|---|---|
alphabet | string | The sequence that should be matched. | Yes. |
classid | array | Filtering: the ID number of the class or an array of the ID numbers. | No. |
offset | integer | The offset to start at. | No. |
limit | integer | The number of elements that should be returned. | No. |
owner | integer | Filtering by owner: the ID number of the object representing the user. | No. |
sort_by | array | The sorting mechanism that should be used. | No. |
An array of hashes (see below) or FALSE.
This function fetches nodes that encapsulate objects which make use of certain keywords. The keyword must be prodived using the "alphabet" parameter. This parameter can be a letter, a part of a word or an entire word - the function will look for keywords that start with the specified sequence. By default, the function will fetch nodes that encapsulate objects of all types created by any user. However, it is possible to only fetch objects of a certain type that are initially created by a certain user, this can be achieved by using the optional "classid" and "owner" parameters. The "offset" and "limit" parameters can be used to limit the result.
The "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 must be the desired sorting method. The second element of the array must be the sorting direction, it can be either true() or false() - ascending or descending. Please note that this parameter works in the very same way as the "sort_by" parameter of the list fetch function. However, it currently only supports the following sorting methods:
Please note that using other sort methods will lead to an error.
The function returns an array of hashes. Each hash consists of the following elements:
Key | Type | Description |
---|---|---|
keyword |
string |
The keyword that was matched. |
link_object |
object |
The node (as a ezcontentobjecttreenode object) that encapsulates an object which uses the matched keyword. |
If no match is found, the function will return FALSE.
{def $list=fetch( 'content', 'keyword', hash( alphabet, 'computer', classid, 3 ) )} {foreach $list as $element} {$element.link_object.name|wash} ({$element.keyword|wash}) <br /> {/foreach}
Outputs the names of nodes that encapsulate objects which make use of keywords starting with the string "computer". In addition, the matched keywords are also printed.
{def $list=fetch( 'content', 'keyword', hash( alphabet, 'computer', classid, array( 1, 3 ) ) )}
Only nodes that encapsulate objects of the specified two classes will be fetched.
{def $list=fetch( 'content', 'keyword', hash( alphabet, 'computer', classid, array( 1, 3 ), owner, 14, sort_by, array( 'modified', false() ) ) )}
Only the nodes/objects that are created by the user that has ID number 14 will be included in the result. The nodes will be sorted by the modification time of the objects; the node that encapsulates the most recently modified object will be the first element in the collection.