You are here:  » Force url to be lowercase

Support Forum



Force url to be lowercase

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

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 support 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.

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 support 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.

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

Perfect! Thanks David.

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

Hi David.

Submitted by support 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.

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

Cheers David,

Chris.

Submitted by TWDesigns on Thu, 2010-04-29 20:07

What would you change to make the Brand and Merchant names appear lowercase in the URL as well?

Submitted by support on Fri, 2010-04-30 08:34

Hi,

In categories.php you'll find the line where the rewritten URL is generated as follows (line 20):

          $item["href"] = tapestry_hyphenate($product["category"])."/";

...REPLACE with:

          $item["href"] = tapestry_hyphenate(strtolower($product["category"]))."/";

And similarly in brands.php, also line 20:

          $item["href"] = tapestry_hyphenate($product["brand"])."/";

...REPALCE with:

          $item["href"] = tapestry_hyphenate(strtolower($product["brand"]))."/";

Cheers,
David.