eZ Find: Cross class filter

Author Message

Anders Berre

Monday 24 January 2011 7:19:49 am

Hi!

Is it possible to do cross class filter with eZ Find. Lets say I want to search in three classes.

Article, Products and Persons

But the search result should only show me articles published in a given timerange.

The first part is easy, show articles published in a given timerange, but the result only shows articles. I want it to show me the products and persons that matches the search word aswell.

Good ideas anyone?

Franck Magnan

Monday 24 January 2011 12:40:55 pm

Hello Anders,

ezfind fetch function looks like :

{set $search=fetch( ezfind,search,
                        hash( 'query', $search_text,
                              'offset', $view_parameters.offset,
                              'limit', $page_limit,
                              'sort_by', hash( 'score', 'desc' ),
                              'facet', $defaultSearchFacets,
                              'filter', $filterParameters,
                              'publish_date', $dateFilter,
                              'spell_check', array( true() ) 
                             ))}

Assuming Article, Product and Persons have class_ids 34, 67 and 55 (for example), you can add one argument to your fetch function to get :

{set $search=fetch( ezfind,search,
                        hash( 'query', $search_text,
                              'offset', $view_parameters.offset,
                              'limit', $page_limit,
                              'sort_by', hash( 'score', 'desc' ),
                              'facet', $defaultSearchFacets,
                              'filter', $filterParameters,
                              'publish_date', $dateFilter,
                              'class_id', array(34, 67, 55),
                              'spell_check', array( true() ) 
                             ))}

Then, ezfind will retrieve only nodes among Articles, Products and Persons.

Hope this helps.

--
Developer at Open Wide

Anders Berre

Tuesday 25 January 2011 12:21:43 am

Hi Franck,

Thanks for taking your time to answer. I think you misunderstod the problem. The problem is not to have define wich classes to use, but to get any other classes as well, when using filter on on of them.

Franck Magnan

Tuesday 25 January 2011 12:08:03 pm

Sorry if I didn't understand your problem.
Perhaps you can read these 3 very interesting tutorials:

hope this helps

--
Developer at Open Wide

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.