You are here:  » using the product name variable

Support Forum



using the product name variable

Submitted by clare on Mon, 2008-02-18 13:56 in

On my products page I am trying to add an rss feed and have tried all morning to work out how to use the product name variable in this bit of code.

In products.php the product name is printed using <?php print $mainProduct["name"]; ?>

But in the extra bit of code I am putting, I need the product name to go into another variable and am not sure if it is possible even.

The new variable is the url of an rss feed, that I want to just add the product name to the end of that url.

The url is declared as
$url="http://site.com/results/";

and I want to tag the product name variable onto the end of that url,

$url="http://site.com/results/"."PRODUCT NAME";

I can add a text string ok like above, but just am not sure how to or if it is possible to use the $mainProduct["name"] variable in the same way, in that place, tagged to the end of the url in the $url variable.

Submitted by support on Mon, 2008-02-18 14:00

Hi Clare,

It should work fine - don't forget to urlencode() the product name. For example:

<?php
  $url 
"http://site.com/results/".urlencode($mainProduct["name"]);
?>

Then of course you can print $url; as normal.

Cheers,
David.

Submitted by clare on Mon, 2008-02-18 14:40

Thanks, that works, I should have asked four hours ago.