Support forum login

©2006-2010 IAAI Software

Contact Us

Force url to be lowercase

Submitted by kiddaclo on Thu, 2010-01-21 22:23.

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.

Submitted by dmorison on Fri, 2010-01-22 09:16.

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

Submitted by kiddaclo on Fri, 2010-01-22 14:16.

David, that's perfect!

Cheers,
Chris.

Submitted by kiddaclo on Sat, 2010-01-23 19:40.

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.

Submitted by dmorison on Sat, 2010-01-23 20:06.

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>&nbsp;";

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>&nbsp;";

Hope this helps!

Cheers,
David.
--
Developer, Price Tapestry
General PHP, MySQL and Affiliate Marketing tech help for Price Tapestry customers at davidmorison.com

Submitted by kiddaclo on Mon, 2010-01-25 22:56.

Perfect! Thanks David.

Cheers,
Chris.

Submitted by kiddaclo on Mon, 2010-02-08 21:16.

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.

Submitted by dmorison on Mon, 2010-02-08 21:40.

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

Submitted by kiddaclo on Mon, 2010-02-08 22:08.

Cheers David,

Chris.