Enable/disable the filter depending of a variable

Author Message

jul tonfa

Thursday 01 October 2009 1:47:41 am

Hi,

I'm working with eZ find and i want to process the search and find all the clients from a specified country.(ie $country). So i'm using the filter.

But i want also that if the country is not specify, ($country = -1 or $country=' ' ) meaning i want to search on all the countries, the search doesn't use the filter.
Because a filter on -1 or ' ' will return me nothing but i want everything.

    {set $search=fetch(ezfind,search,
                       hash(query,$search_text,
                            section_id,$search_section_id,
                            filter,concat('client/pays:',$country),
                            subtree_array,$search_sub_tree,
                            class_id,$search_contentclass_id,
                            class_attribute_id,$search_contentclass_attribute_id,
                            offset,$view_parameters.offset,
                            limit,$page_limit))}

If you have any ideas, I will be grateful.
Thanks

Paul Borgermans

Tuesday 20 October 2009 2:22:35 am

You should add template logic and construct a different query or if you use a select form element, let the value for any country be [* TO *]

hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

jul tonfa

Monday 26 October 2009 8:54:46 am

Thanks paul, it works well like that :)
Jul

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 30 2025 16:37:21
Script start
Timing: Jan 30 2025 16:37:21
Module start 'layout'
Timing: Jan 30 2025 16:37:21
Module start 'content'
Timing: Jan 30 2025 16:37:21
Module end 'content'
Timing: Jan 30 2025 16:37:21
Script end

Main resources:

Total runtime0.0254 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.4063151.2422
Module start 'layout' 0.00560.0059 739.6484220.7500
Module start 'content' 0.01150.0125 960.3984999.0391
Module end 'content' 0.02400.0013 1,959.437533.9922
Script end 0.0253  1,993.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00259.8562140.0002
Check MTime0.00103.9103140.0001
Mysql Total
Database connection0.00072.755410.0007
Mysqli_queries0.005220.546930.0017
Looping result0.00000.070510.0000
Template Total0.00093.710.0009
Template load0.00083.011010.0008
Template processing0.00020.670010.0002
Override
Cache load0.00062.168010.0006
General
dbfile0.00166.355680.0002
String conversion0.00000.034840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs