Force url to be lowercase
Hi,
Is there a way to force the product url to be lowercase? at the moment it is for example www.bluewidgets.com/Blue-Widgets
I'd also like to do the same with my meta keywords and force them lowercase currently I'm inserting the product title like so:
$header["meta"]["keywords"] = translate("cheap ").htmlentities($q,ENT_QUOTES,$config_charset).translate(",compare ").htmlentities($q,ENT_QUOTES,$config_charset).translate(",blue,widgets,cheap");Cheers,
Chris.
Hi David,
One small niggle with this, the banner on my product page is now lowercase also. Is there a way to exclude this from being converted?
Cheers,
Chris.
Hi Chris,
Sure - the banner is currently set by the following code on line 10 of products.php:
$banner["h2"] = translate("Price search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong> ";As it uses $q (which has been strtolower()'d on your site), the trick is to move this line further down the script, and then to use the actual product name from the database. To do this, CUT the above line, and then PASTE it in immediately before the following code which can be found at line 50:
$header["title"] = htmlentities($q,ENT_QUOTES,$config_charset);...and then MODIFY it as follows:
$banner["h2"] = translate("Price search results for")." <strong>".htmlentities($product["products"][0]["name"],ENT_QUOTES,$config_charset)."</strong> ";Hope this helps!
Cheers,
David.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com
Hi David.
One more place I need the url changing to lowercase and I can't seem to track it down it's the related products on the product page.
Hi Chris,
That would be line 89 of products.php, currently:
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($related["normalised_name"]).".html";...REPLACE with:
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate(strtolower($related["normalised_name"])).".html";Cheers,
David.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com
Hi Chris,
Sure - regarding the meta tags, simply replace the above code with:
$header["meta"]["keywords"] = translate("cheap ").htmlentities($q,ENT_QUOTES,$config_charset).translate(",compare ").htmlentities(strtolower($q),ENT_QUOTES,$config_charset).translate(",blue,widgets,cheap");For the product URLs, it should also just be a case of adding strtolower() around the product name wherever a product URL is created, as MySQL text search is not case sensitive. To do this, make the changes a follows:
search.php (line 287):
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";...REPLACE with:
$searchresults["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate(strtolower($product["normalised_name"])).".html";index.php (line 63 - for Featured Product URLs):
$featured["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["normalised_name"]).".html";...REPLACE with:
$featured["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate(strtolower($product["normalised_name"])).".html";...and finally in reviews.php (line 47 - for links back to the product page):
$rows[$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($row["normalised_name"]).".html";...REPLACE with:
$rows[$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate(strtolower($row["normalised_name"])).".html";Hope this helps!
Cheers,
David.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com