This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Learn » eZ Publish » Need for speed - How to use eZ Find...

Need for speed - How to use eZ Find search fetch instead of standard content list/tree fetch

Tuesday 13 July 2010 10:27:45 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Step 4: Examples

Few simple examples on how to replace fetch content calls with eZ Find calls.

Example 1

Using standard function

{fetch( 'content', 'list',
     hash( 'parent_node_id', 100,
           'class_filter_type', 'include',
           'class_filter_array, array('article'),
           'sort_by', array( array('modified',false()),
                             array( 'attribute', true(),'article/title') )

Using eZ Find

{fetch( 'ezfind', 'search',
     hash( 'filter', 'main_parent_node_id:100',
           'class_id', array('article'),
           'sort_by', hash( 'modified', 'desc', 'article/title', 'asc' ) ) )}

Listing only child nodes is solved with special filter. Including classes is simpler. Sorting is a bit different and it needs only one hash, with no nested arrays.


Example 2

Using standard function

{fetch( 'content', 'tree',
        hash( 'parent_node_id',     100,
              'ignore_visibility', true(),
              'limit', 20,
              'offset', 0,
              'attribute_filter', array( array( 'review/rating',
                                                array( 0, 2 ) ) ) ) )}

Using eZ Find

{fetch( 'ezfind', 'search',
        hash( 'subtree_array', 100,
              'ignore_visibility', true(),
              'limit', 20,
              'offset', 0,
              'filter', array('review/rating:[0 TO 2]') ) )}

This example shows even more similarity between standard fetch function and eZ Find search fetch function. Only difference is the filter with the way how condition is constructed.



Printer Friendly version of the full article on one page with plain styles


Proudly Developed with from