You are here:  » Custom content in product.php

Support Forum



Custom content in product.php

Submitted by chrisst1 on Thu, 2013-04-11 16:19 in

Hi David

Just a quickie (maybe) i've added a sql query to get extra content as below, have I got it right, it works, just wanted to check.

  if ($q)
  {
    $banner["h2"] = translate("Price search results for")." <strong>".htmlentities($q,ENT_QUOTES,$config_charset)."</strong>&nbsp;";
    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($q)."'";
    $numRows = database_querySelect($sql,$rows);
    if ($numRows)
    {
      // if ($config_useVoucherCodes === 1)
      foreach($rows as $k => $row)
      {
        $rows[$k]["normalprice"] = $row["price"];
      }
      if ($config_useVoucherCodes === 1)
      {
        $rows = tapestry_applyVoucherCodes($rows);
      }
      // START CUSTOM
      foreach($rows as $k => $row)
      {
        // query custom fields from the feeds table to include as extra merchant details
        $sql2 = "SELECT merchant_description FROM `".$config_databaseTablePrefix."feeds` WHERE merchant='".database_safe($row["merchant"])."'";
        database_querySelect($sql2,$rows2);
        $rows[$k]["merchant_description"] = $rows2[0]["merchant_description"];
      }
      // END CUSTOM
      foreach($rows as $k => $row)
      {
        $rows[$k]["reviewHREF"] = tapestry_reviewHREF($row);
        if ($config_useRewrite)
        {
          $rows[$k]["merchantHREF"] = $config_baseHREF."merchant/".urlencode(tapestry_hyphenate($row["merchant"]))."/";
        }
        else
        {
          $rows[$k]["merchantHREF"] = $config_baseHREF."search.php?q=merchant:".urlencode($row["merchant"]).":";
        }
        if ($config_useInteraction)
        {
          if ($rows[$k]["reviews"])
          {
            $rows[$k]["extraHTML"] = "<p>".tapestry_stars($rows[$k]["rating"],"")."&nbsp;<a href='#reviews'>".$rows[$k]["reviews"]." ".translate("Reviews")."</a></p>";
          }
          else
          {
            $rows[$k]["extraHTML"] = "<p><a href='#reviews'>".translate("Review This Product")."</a></p>";
          }
        }
      }

Thanks

Chris

Submitted by support on Thu, 2013-04-11 17:14

Looks fine Chris, nothing there that can be significantly optimised (unless your `feeds` table was huge, which is unlikely!) so all good!

Cheers,
David.
--
PriceTapestry.com