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.

eZ debug

Timing: Jan 18 2025 02:51:06
Script start
Timing: Jan 18 2025 02:51:06
Module start 'layout'
Timing: Jan 18 2025 02:51:06
Module start 'content'
Timing: Jan 18 2025 02:51:07
Module end 'content'
Timing: Jan 18 2025 02:51:07
Script end

Main resources:

Total runtime1.3858 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 589.0313152.6250
Module start 'layout' 0.00600.0029 741.656339.4531
Module start 'content' 0.00891.3755 781.1094493.2969
Module end 'content' 1.38440.0013 1,274.40638.3203
Script end 1.3857  1,282.7266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2369160.0002
Check MTime0.00130.0940160.0001
Mysql Total
Database connection0.00090.063310.0009
Mysqli_queries1.337396.5049540.0248
Looping result0.00050.0347520.0000
Template Total1.355897.820.6779
Template load0.00200.145720.0010
Template processing1.353797.690620.6769
Template load and register function0.00010.009210.0001
states
state_id_array0.00040.029410.0004
state_identifier_array0.00110.082920.0006
Override
Cache load0.00160.1163240.0001
Sytem overhead
Fetch class attribute can translate value0.00100.074820.0005
Fetch class attribute name0.00140.098930.0005
XML
Image XML parsing0.00210.148820.0010
class_abstraction
Instantiating content class attribute0.00000.000530.0000
General
dbfile0.00210.1539160.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs