You are here:  » How to generate its Product URL from database

Support Forum



How to generate its Product URL from database

Submitted by technoarenasol on Thu, 2012-09-13 07:37 in

Hello David

After retrieving name of product from database how to generate its url

Submitted by support on Thu, 2012-09-13 08:00

Hi,

There's a library function to generate the product page URL of a product; but it takes as its input an associative array representation of an entire `products` table row - although from that it only uses the normalised_name field which is the URL safe version of a product name as generated by the tapestry_normalise() function.

So let's say you have your product name in the variable $productName you can generate the URL and display a link as follows:

<?php
  $productName 
"Blue Widget";
  
$productLink tapestry_productHREF(array("normalised_name"=>tapestry_normalise($productName)));
  print 
"<a href='".$productLink."'>".$productName."</a>";
?>

Hope this helps!

Cheers,
David.
--
PriceTapestry.com