Hi David
Site Pet Price
On my site I have a nav bar that is for general pet types (cats, dogs...).
It basically uses a search term $_GET["q"] = " dog";
but I don't get nearly half the results, as most product names don't feature the pet type.
I also use your codes for drop downs on the merchant, brand and category, which works really well.
In the feeds I have another column that lists Cats, Dogs, Rabbits... and I wondered how to go about using this as the navigation menu.
I assume that I have to click the field Pet Type in the extras, but don't know how to implement that into the navigation so that it brings up all the results for that pet. (Or am I "Barking" up the wrong tree hahaha!).
So in effect when someone clicks on dogs, can it bring up all the records from the pet type field which = dogs?
thanks in advance
Kelly
Hi David
I have had success getting the feeds with the new column into the database - thanks for you help.
What I also have done is to create a copy of brand.php and change it to pets.php and changed all the instances of brand to pet,
so now I have an index of the pets and I have also used the code:
<?php
$sql = "SELECT DISTINCT(pet) as pet FROM `".$config_databaseTablePrefix."products` ORDER BY pet";
if (database_querySelect($sql,$rows))
{
foreach($rows as $row)
{
if ($config_useRewrite)
{
$href = $config_baseHREF."pet/".tapestry_hyphenate($row["pet"])."/";
}
else
{
$href = $config_baseHREF."search.php?q=pet:".urlencode($row["pet"]).":";
}
print "<li><a href='".$href."'>".$row["pet"]."</a></li>";
}
}
?>
Still got a bit of work to do on the site, but this will make my site so much easier for people to use!
Extremely grateful for all your help and advise. I think PT is the best thing since sliced bread
Hi David,
I have added a further 20 fields to the database to input what ever extra information I need to display. I have called these fields field1, field2,....field20 so that I will be easily able to replicate the site rather than changing field names in several pages of code.
One of my fields in the database contains colours and I will have a link to pink products as follows
http://www.mysite.co.uk/search.php?q=field1:pink
Is there anyway I can change "field1" to "colour" in the url, or change the URL to look like http://www.mysite.co.uk/Pink Products/
I think I saw this mentioned somewhere on the site before.
Thanks
Adrian
Hi Adrian,
Sure - you can just apply the appropriate mappings at the point immediately before the field name is used to construct the SQL (although note that whilst your database is then generic your code unfortunately would not be...!)
In search.php; the field:value search queries are handled by a common block of code where the "field" and "value" parts are used to create a WHERE clause of field='value'. This is done by the following code starting at line 36:
case "merchant":
// pass through to category
case "category":
// pass through to brand
case "brand":
$where = " ".$parts[0]."='".database_safe($parts[1])."' ";
To add the generic fields and then the appropriate mappings, change the above code as follows, in this case adding the fields "colour" (field1) and "size" (field2):
case "merchant":
// pass through to category
case "category":
// pass through to brand
case "brand":
// pass through to generic fields (add one line like this for each one)
case "colour":
case "size":
// map generic fields to fieldn.. (add one line like this for each one)
if ($parts[0]=="color") $parts[0]="field1";
if ($parts[0]=="size") $parts[0]="field2";
// back to the normal code
$where = " ".$parts[0]."='".database_safe($parts[1])."' ";
Creating a /PinkProducts/ directory (I would advise against using spaces in a directory name) is simply a case of adding another rule to .htaccess; for example:
RewriteRule ^PinkProducts/$ search.php?q=colour:Pink:&%{QUERY_STRING} [L]
Cheers,
David.
Hi Kelly,
I think the neatest way to go about this would be to add a new field to your database called "pet" based on the instructions in the following thread:
http://www.pricetapestry.com/node/313
Having done that, a new search modifier (like category: or brand:) can be added to search.php simply by looking for the following code in search.php (line 36 in the distribution)
case "merchant":
// pass through to category
...and inserting the new case for "pet" immediately infront of this code, like this:
case "pet":
// pass through to merchant
This would enable you to use the following style of query:
pet:Cat
So, assuming that your cat.php, dog.php pages just set $q (or perhaps $_GET["q"]) before including the search code, just change the query to pet:Cat etc. instead.
Now it might be that a little more code is required to populate the "Pet" field accurately based on the value of your pet type fields, and another easy option is to dynamically set this field during import if there is no pet type field for a particular feed - for example by looking for pet names in the product name & description and then setting "pet" as required. I'll work through this with you if required...
Hope this helps!
Cheers,
David.