customizing the search form

Author Message

justin kazadi

Friday 08 August 2008 3:01:50 am

hello all,
i want to know how can i modified the default search from by adding for exemple two fields .

i wanna have samethings like this :

<form action={'/content/search'|ezurl()} method='post'>
<label>Country:</label>

<select>
<option name="countries">RDC</option>
<option>BELGIQUE</option>
<option>NORVEGE</option>
</select>

<label>Town:</label>

<select name="towns">
<option>kinshasa</option>
<option>bruxelles</option>
<option>paris</option>
</select>
<label>Tag:</label>
<input type="text" name="SearchText" />
<input type="submit" name="SearchButton" value="search" />
</form>

i have try this but it didn 't work.
i need same suggestion.
thanks in advance

The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.

Albert Einstein

Gabriel Finkelstein

Monday 11 August 2008 2:11:57 pm

I think you should better use a filter rather than a search.

Something like:

<form action='some_url' method='get'>

<label>Country:</label>
<select name="country">
<option value="xx">RDC</option>
<option value="xx">BELGIQUE</option>
<option value="xx">NORVEGE</option>
</select>

<label>Town:</label>
<select name="town">
<option value="xx">kinshasa</option>
<option value="xx">bruxelles</option>
<option value="xx">paris</option>
</select>

<label>Tag:</label>
<input type="text" name="SearchText" />
<input type="submit" name="SearchButton" value="search" />
</form>

Where:
some_url = url to a dummy node
xx = id of the town/country for the datatype you are using (if you use objectrelations, then xx = object id)

And inside the template for some_url:

{def $results=fetch(content, tree, hash( parent_node_id, 2,
                                                         attribute_filter, array('and',
                                                                   array('myclass/country','=',$view_parameters.country),
                                                                   array('myclass/town','=',$view_parameters.town),
                                                                 array('myclass/body','like',concat('*',$view_parameters.SearchText,'*')) ))}

Where myclass/country, myclass/town, myclass/body are the class and attributes where you want the search to be performed.

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