You are here:  » Sidebar Filter

Support Forum



Sidebar Filter

Submitted by thelegacy on Sun, 2011-03-06 21:28 in

Cheers David,

Are there any mods posted here to add a filter to the sidebar, similiar to the Sidebar filters in the new distribution?

What I mean is, that I'd like to incorporate form fields dynamicly throughout the site, calling this into the pages from the html directory to parts where I want it to show similiar to the Sidebar mod.
By merchant:
By category:
By brand:
By price: $ to $

I already have the Sidebar filters placed, and it comes up when a product in searched for in my left sidebar, that works fine when searching etc.. but I need the option from the main and a couple other pages to make finding products easier.

Hopefully I've explained what I am trying to do here.

Thanks in adavance,

Ray

Submitted by support on Mon, 2011-03-07 08:51

Hi Ray,

All the sidebar filters script relies upon is a $where clause being present, which it uses to make the drop-downs relevant to the query (e.g. only categories present in the search results are offered in the category drop down).

Therefore, it would be straight forward to make the sidebar filters code into a generic "advanced" search form, simply by adding a "q" textbox and setting $where = "1"; if NOT being shown on the search results page!

Firstly, you'd need to make sure that the sidebar filters code shows up wherever you want it to in addition to the search results (let me know if you need any assistance with this)

Then, in your sidebar filters code, replace:

if (strpos($_SERVER["PHP_SELF"],"search.php"))

with:

if (1)

Then look for the following code just a few lines down:

  print "<input type='hidden' name='q' value='".htmlentities($q,ENT_QUOTES,$config_charset)."' />";
  print "<strong>Filter Results</strong><br /><br />";

...and REPLACE with:

  if ($navigation["resultCount"])
  {
    print "<strong>Filter Results</strong><br /><br />";
    print "<input type='hidden' name='q' value='".htmlentities($q,ENT_QUOTES,$config_charset)."' />";
  }
  else
  {
    print "<strong>Search</strong><br /><br />";
    print "<input type='text' name='q' />";
    $where = "1";
  }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by thelegacy on Mon, 2011-03-07 21:07

Hi David,

Thanks for this, never thought of the "where 1" statement, at any rate works as I was attempting to do, I only use this on a couple of pages, and the Sidebar filter for all others, appears to work best for me.

Ray