Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-01-05 19:19:57

blur
Member
Registered: 2008-09-08
Posts: 18

Advanced search. Filtering results

Hi, I’m trying to do an advanced search for my website by using wet_haystack, glz_custom_fields and adi_gps plugins but isn’t working as i wish. Hope somebody can give me a tip:

I have a search that allow the user to find cars by name, price, color, model etc… something like:

<form action="foo" method="get" name="foo">
  <input name="q" id="search-input" type="text">
  <select name="color" id="color"">
    <option value="red">red</option>
    <option value="green">green</option>
    <option value="blue">blue</option>
</select>
</form>

That’s produce an url like: http://foo.com/?q=Bmw&color=red&search-btn=Go. Then in my page results template i’m using:

<txp:adi_gps name="color" quiet="1" />
<txp:if_variable name="color" value="">
  <!-- No color filter -->
  <txp:article form="search_results" />
<txp:else />
  <!-- Color filter -->
  <txp:article_custom form="search_results" color="<txp:variable name="color" />" />
</txp:if_variable>

That works if the user type on the search box OR if he makes a selection on the color combo, but no for both. My question is: how can i show results combining the User Query and the filter of the color combo? Something like “BMW” color=blue

Last edited by blur (2012-01-05 19:20:26)

Offline

#2 2012-01-05 19:23:48

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Advanced search. Filtering results

  <txp:article_custom form="search_results" color="<txp:variable name="color" />" />

This should be:

 <txp:article_custom form="search_results" color='<txp:variable name="color" />' />

Single quotes when using txp:tags inside other txp:tags! :D


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2012-01-05 19:39:29

blur
Member
Registered: 2008-09-08
Posts: 18

Re: Advanced search. Filtering results

maniqui wrote:

Single quotes when using txp:tags inside other txp:tags! :D

Thanks. I put the single quotes but doesn’t work… the search result keep showing the articles with the color value but ignores what the user writes on the search box.

Offline

#4 2012-01-05 22:23:49

blur
Member
Registered: 2008-09-08
Posts: 18

Re: Advanced search. Filtering results

I realize that the problem was the article_custom tag. Replacing it for <txp:article /> do the trick.

<txp:adi_gps name="color" quiet="1" />
<txp:if_variable name="color" value="">
  <!-- No color filter -->
  <txp:article form="search_results" />
<txp:else />
  <!-- Color filter -->
  <txp:article form="search_results" color='<txp:variable name="color" />' />
</txp:if_variable>

Offline

Board footer

Powered by FluxBB