keyword
Summary
Fetches nodes that use keywords starting with a given sequence.Usage
fetch( 'content', 'keyword', hash( 'alphabet', alphabet, [ 'classid', classid, ] [ 'limit', limit, ] [ 'offset', offset, ] [ 'owner', owner, ] [ 'sort_by', sort_by, ] ) )
Parameters
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. |
Returns
An array of hashes (see below) or FALSE.
Description
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:
- class_identifier
- class_name
- modified
- name
- published
- section
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.
Examples
Example 1
{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.
Example 2
{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.
Example 3
{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.
Balazs Halasy (06/02/2004 12:06 pm)
Svitlana Shatokhina (17/01/2007 1:33 pm)
Comments
There are no comments.