Skip to the content
Documentation

list

No ratings yet

Summary

Fetches the phrases that have been searched ordered by their usage frequency.

Usage

fetch( 'search', 'list',
         hash( [ 'offset', offset, ]
               [ 'limit',  limit   ] ) )

Parameters

Name Type Description Required
offset integer The offset to start at. No.
limit integer The number of items that should be returned. No.

Returns

An array of hashes (see below) or FALSE.

Description

This function fetches the phrases that have been searched on the site. The phrases are ordered by their usage frequency. If two or more phrases have the same usage frequency, they are ordered by the number of nodes that match the search conditions.

The "offset" and "limit" parameters are optional and can be used to limit the result. If the "offset" and "limit" parameters are omitted, the function will return all the search phrases.

The function returns an array of hashes. The hashes consist of the following elements:

Key Type Description
id string The ID number of the search phrase.
phrase string The text of the search phrase.
phrase_count string The number of times the phrase has been searched for.
result_count string The number of nodes that match the search conditions (average search results that have been returned).

If no search phrases are found, the function returns FALSE.

Examples

Example 1

{def $search_list=fetch( 'search', 'list' ) )}
{foreach $search_list as $s}
        {$s.id } : {$s.phrase}<br />
{/foreach}

Outputs all phrases that have been searched for along with their ID numbers.

Example 2

{def $search_list=fetch( 'search', 'list', hash( 'limit','10'  ) )}
{foreach $search_list as $s}
        {$s.phrase } : {$s.phrase_count}<br />
{/foreach}

Outputs the ten most frequently searched phrases and their usage frequency.

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.