Create form filter
-
OK next big challenge. I have a page that generates matching properties, matching the criteria from the current property to other properties. I am basically setting a bunch of variables, then running the loop, then presenting the results, then closing the loop.
I want to use the following to create a basic filter on City –
[form action=]
<i class=”fa fa-street-view” aria-hidden=”true”></i> I’m looking for an agent in
[select name=filter]
[for each=property-city]<option value=[each id]>[each]</option>
[/for]
[/select][input type=submit]
[/form]I have used this before, but on a much simpler page.
Since I want this to display BEFORE the search results, I have this code before the loop occurs (otherwise I get one of these for every match). But I’m having a problem getting the filter to narrow the result set. I’ve basically used
[set var=…]
[set var2=..][pass global=query fields=filter,etc,etc2,etc]
[loop]
Run a bunch of [if]s to find matching results.
[run a bunch of calculations, set a bunch of variables on results for the display of the content][if taxonomy property-city field=id value={FILTER}]
CONTENT DISPLAY CODE GOES HERE
[/if]
[/loop]Filter does show up in the URL as a parameter, but when I select a value from the dropdown list, it doesn’t filter the result. Also I can’t seem to figure out how to set the OPTION SELECTED on the form itself based on the filter…
Any suggestions?
David
The topic ‘Create form filter’ is closed to new replies.