search using two attributs

Author Message

Hassan CHAKROUN

Tuesday 14 June 2011 6:14:04 am

Hello ,

In a search form, I have two inputs that I have to fill to execute the search.

the first for person name and the second for his town.

is it possible to search people who has a name 'x' and lives in town 'y'

thank you

Abdallah Mostafa

Tuesday 14 June 2011 6:46:51 am

You will probably need to use fetch list function combined with attribute_filter parameter.

Something like this:

fetch('content', 'list', hash(
    'parent_node_id', $parentNodeID,
    'class_filter_type', 'include',
    'class_filter_array', array('class_name'),
    'attribute_filter', array(
        'and',
        array('class_name/name', 'like', '*name*'),
        array('class_name/twon', '=', 'twon')
    )
))}

Make sure to replace [class_name] with the name of your class. And also make sure that $parentNodeID contains the correct value.

And please note that I used the "like" operator when for the name attribute, not equal as you proposed in your question. If you want to return exact matches only then you'll need to replace "like" with "=", and get rid of the asterisks that surround the string.

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