I am create new gender custom field .now i want to add this field into sidebar .
please note I am use sidebar with grid/list view
technoarenasol
thanks david for reply
but i didn't understand what exactly i have to do
what other section i have to modify
does i have to copy each code where categoryFilter comes and then replace the gender in place of category
can you please tell in detail because i need to add more new filter in future.
thanks
Hi technoarenasol,
In html/searchresults.php it is actually only the modification described above - but in search.php I suggest using categoryFilter as a template, and whenever you add a new filter COPY each of the following sections, and then PASTE back in on the next line but replacing "category" with "gender" or the name of the new filter you are adding. It must match the name of the new field that you added to the database....
The following line numbers are based on the SidebarFilters.zip version of search.php:
Line 16:
$categoryFilter = ($_GET["categoryFilter"]?$_GET["categoryFilter"]:"");
Lines 57-61:
if ($categoryFilter)
{
$priceWhere .= " AND category = '".database_safe($categoryFilter)."' ";
}
Lines 317-320:
if ($categoryFilter)
{
$sortHREF .= "categoryFilter=".urlencode($categoryFilter)."&";
}
Lines 410-413:
if ($categoryFilter)
{
$sort .= "&categoryFilter=".urlencode($categoryFilter);
}
Cheers,
David.
--
PriceTapestry.com
Hi David,thanks for replay but i am not find above in search.php
This is my search.php file
{code saved}
Hi,
I just forwarded to you by email a copy of your search.php with support for genderFilter - if you're not sure about the corresponding modifications to html/searchresults.php if you would like to reply with that file as an attachement I'll add the code for you...
Cheers,
David.
--
PriceTapestry.com
Hey, I was wondering would this solution still work or would there need to be changes to it?
Hi,
Code for the filters is contained within search.php and html/searchresults.php - what I suggest is to take "categoryFilter" as a template and replicate every section of code relating to "categoryFilter" for your new "genderFilter" - e.g. replacing "category" with "gender" in each copied section.
For example, in search.php the first copy would be this new line:
$genderFilter = ($_GET["genderFilter"]?$_GET["genderFilter"]:"");
...and in html/searchresults.php the first copy would be this new section:
$sql1 = "SELECT DISTINCT(gender) FROM `".$config_databaseTablePrefix."products` WHERE ".$where." AND gender <> '' ORDER BY gender";
if (database_querySelect($sql1,$rows1))
{
print "<label form='cf'>By gender:</label><br />";
print "<select style='width:150px;' id='cf' name='genderFilter'>";
print "<option value=''>All</option>";
foreach($rows1 as $row)
{
$selected = ($_GET["genderFilter"]==$row["gender"]?"selected='selected'":"");
print "<option value='".htmlentities($row["gender"],ENT_QUOTES,$config_charset)."' ".$selected.">".$row["gender"]."</option>";
}
print "</select>";
print "<br /><br />";
}
If you're not sure what other sections of code to copy just let me know!
Cheers,
David.
--
PriceTapestry.com