How to create a filter form

Author Message

Wei Dai

Tuesday 19 August 2008 12:22:35 am

Hi,
I need create a form with two dropdowns. Each dorpdown is a criteria based on the value of an attribute, e.g. a salon class has attribute of topic and location. The values of the attributes need be listed in the dropdowns, e.g. topic: Aerospace, Agriculture-Food...; location: Paris, London...

Other input fields maybe added, such as the start date and end date for user to specify a range of the date in which the salons will take place.

Basically, this form will be put on a "list all salons" template/page, and provide some sort of sorting & filtering function.

I was wonder is there a way to build this? I think the action for the form may not be the /content/action right? and also, see no need to use the /content/search. I just need a way to pass the input values of the form to the list template code.

If I am right, which module/view should I use for the form? and then, I just custom view parameter to pass the variable?

Certified eZ Publish 4 developer looking for develop information & collaboration.

Gabriel Finkelstein

Thursday 21 August 2008 11:52:09 am

You should do something like:

<form action="{$node.url_alias}" method="GET">
   <select name="(location)">
      {foreach $locations as $location}
         <option value="{$location.id}">{$location.name}</option>
      {/foreach}
   </select>
   <input type="submit" value="Filter" />
</form>

{def $salons=fetch(content, list, hash( parent_node_id, $node.node_id,
                                                       attribute_filter, array( array('salon/location', '=', $view_parameters.location) )}

$location is just an example. Instead you could loop through a ezselection or ezobjectrelation class attribute.
You should also consider when $view_parameters.location is not defined (the list is unfiltered).

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