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.

eZ debug

Timing: Jan 18 2025 14:54:55
Script start
Timing: Jan 18 2025 14:54:55
Module start 'layout'
Timing: Jan 18 2025 14:54:55
Module start 'content'
Timing: Jan 18 2025 14:54:55
Module end 'content'
Timing: Jan 18 2025 14:54:55
Script end

Main resources:

Total runtime0.0182 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0085 587.9141152.6250
Module start 'layout' 0.00850.0028 740.539139.4453
Module start 'content' 0.01140.0053 779.984489.4453
Module end 'content' 0.01660.0016 869.429730.3047
Script end 0.0182  899.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002714.9046140.0002
Check MTime0.00105.7615140.0001
Mysql Total
Database connection0.00168.921510.0016
Mysqli_queries0.003016.542330.0010
Looping result0.00000.065610.0000
Template Total0.00137.110.0013
Template load0.00073.729110.0007
Template processing0.00063.310810.0006
Override
Cache load0.00052.551610.0005
General
dbfile0.00126.672880.0002
String conversion0.00000.045940.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