Hi David,
How would I achieve a URL structure like this for product pages?
I.e example.com/televisions/sony/customfield
Thanks
Hi,
Sure - firstly, since not all fields are included in the search SELECT query, in search.php look for the following code at line 476;
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
...and REPLACE with:
$sql2 = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
Then the product page URL can be constructed as required at line 66 in includes/tapestry.php:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"])).".html";
So to include category, brand and customfield (using hyphen in place of empty values), use:
$href = $config_baseHREF; $href .= ($product["category"]?urlencode(tapestry_hyphenate($product["category"])):"-")."/"; $href .= ($product["brand"]?urlencode(tapestry_hyphenate($product["brand"])):"-")."/"; $href .= ($product["customfield"]?tapestry_hyphenate(urlencode($product["customfield"])):"-")."/"; $href .= urlencode(tapestry_hyphenate($product["normalised_name"])).".htm"; return $href;
Finally, edit .htaccess and add at the very end of the file:
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)/(.*)/(.*).html$ products.php?q=$1&rewrite=4&%{QUERY_STRING} [B,L]
(rules not containing a known common base need to go last)
Hope this helps!
Cheers, David. -- PriceTapestry.com
©2006-2025 IAAI Software | Contact Us | Privacy Policy
Hi,
Sure - firstly, since not all fields are included in the search SELECT query, in search.php look for the following code at line 476;
$sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
...and REPLACE with:
$sql2 = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";
Then the product page URL can be constructed as required at line 66 in includes/tapestry.php:
return $config_baseHREF."product/".urlencode(tapestry_hyphenate($product["normalised_name"])).".html";
So to include category, brand and customfield (using hyphen in place of empty values), use:
$href = $config_baseHREF;
$href .= ($product["category"]?urlencode(tapestry_hyphenate($product["category"])):"-")."/";
$href .= ($product["brand"]?urlencode(tapestry_hyphenate($product["brand"])):"-")."/";
$href .= ($product["customfield"]?tapestry_hyphenate(urlencode($product["customfield"])):"-")."/";
$href .= urlencode(tapestry_hyphenate($product["normalised_name"])).".htm";
return $href;
Finally, edit .htaccess and add at the very end of the file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)/(.*).html$ products.php?q=$1&rewrite=4&%{QUERY_STRING} [B,L]
(rules not containing a known common base need to go last)
Hope this helps!
Cheers,
David.
--
PriceTapestry.com