You are here:  » product/product

Support Forum



product/product

Submitted by philstone on Wed, 2006-10-18 10:41 in

Hi dave

using the code below in my products page now, but for some reason it comes up product/product in the link

 print "<div align='center'>";
$sql = "SELECT * FROM `".$config_databaseTablePrefix."featured` ORDER BY RAND() LIMIT 5";
  if (database_querySelect($sql,$rows))
  {
    $sqlNames = array();
    foreach($rows as $featured)
    {
      $sqlNames[] = "'".$featured["name"]."'";
    }
    $sqlIn = implode(",",$sqlNames);
    $sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants FROM `".$config_databaseTablePrefix."products` WHERE name IN (".$sqlIn.") GROUP BY name";
    database_querySelect($sql,$rows);
    $featured["products"] = $rows;
    foreach($featured["products"] as $k => $product)
    {
      if ($config_useRewrite)
      {
        $featured["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
        $featured["products"][$k]["reviewHREF"] = "review/".tapestry_hyphenate($product["name"]).".html";
      }
      else
      {
        $featured["products"][$k]["productHREF"] = "products.php?q=".urlencode($product["name"]);
        $featured["products"][$k]["reviewHREF"] = "reviews.php?q=".urlencode($product["name"]);
      }
    }
  }

an example can be seen Here

What can you see i'm doing wrong, tried several things but now working.

thanks

phil

Submitted by support on Wed, 2006-10-18 11:02

Hi Phil,

Because you are using mod_rewrite, you are already in the product/ directory when building the links, so you don't need to include product/ again which is why you are getting it twice.

However, I think the best way to fix it is to use $config_baseHREF infront of the links, like this (from your code above):

      if ($config_useRewrite)
      {
        $featured["products"][$k]["productHREF"] = $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
        $featured["products"][$k]["reviewHREF"] = $config_baseHREF."review/".tapestry_hyphenate($product["name"]).".html";
      }

That should do the trick!
Cheers,
David.

Submitted by philstone on Wed, 2006-10-18 13:18

Thanks yet again Dave!