You are here:  » Filtered Sitemap

Support Forum



Filtered Sitemap

Submitted by gregor on Thu, 2011-04-28 03:49 in

I have a new site that I built using the same database as another site. The new site only shows a subset of the items on the main site. I did this by adding to the where clauses in all of the selects (see below). It seems to work fine but when I looked at the sitemap it had entries for all of the items on the main site. I only want the sitemap to include the items I'm showing on this site. Is there a way for me to filter the items that are added to the sitemap? I might filter by category or by a word in the product name (or whatever filter I might need). I tried making a change to the select statement in sitemap.php (similar to what I did in search.php), but it did not work (php errors).

The code I added to the where is similar to this:

" AND search_name LIKE '%widget%'";

I'm including only the products with the word 'widget' in the product name. This works for normal searches but not for the sitemap.

What do you think? Is this something that should be easy to do?

Thanks,
Gregor

Submitted by support on Thu, 2011-04-28 08:09

Hi Gregor,

The modification in sitemap.php should be to line 16 - try replacing:

    $sql = "SELECT normalised_name FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($_GET["filename"])."' LIMIT ".$start.",".$limit;

with:

    $sql = "SELECT normalised_name FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($_GET["filename"])."' AND search_name LIKE '%widget%' LIMIT ".$start.",".$limit;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by gregor on Thu, 2011-04-28 13:26

Thank you. That's the code I tried, but it didn't work on my local environment. I uploaded it to my website and it does work there. I guess I have something wrong with my local php setup. Sorry to bother you with it.