You are here:  » Getting products to display in other directories

Support Forum



Getting products to display in other directories

Submitted by cmentgp on Wed, 2008-07-02 19:19 in

Hi,

I have installed PT in the www.site.com/ptshop/ directory and would like to have some product results appear in the root directory. I tried to hack up the following code but no luck (not that good with php :-( ). Am i better off just re-installing PT in my root directory?

<?php
  $path_to_pricetapestry = "/home/site/public_html/ptshop/";
  require($path_to_pricetapestry."includes/config.php");
  require($path_to_pricetapestry."includes/tapestry.php");
  require($path_to_pricetapestry."includes/database.php");
  require($path_to_pricetapestry."html/header.php");
  // now preload $_GET["q"] to be the query you want to display search results for
  $_GET["q"] = "cars";
  $_GET["sort"] = "priceAsc";
  // now bring in the search code
  require($path_to_pricetapestry."searchcode.php");
  // now use Price Tapestry's search results HTML module to display the results
  require($path_to_pricetapestry."html/searchresults.php");
  // and finally the common footer, although you could always add more content first
  require($path_to_pricetapestry."html/footer.php");
?>

Thanks for your help.
cmentgp

Submitted by support on Tue, 2008-07-08 09:16

Hi,

It should be possible to do it like this - firstly what error or effect are you getting from this code? Have you created searchcode.php as this is not part of the Price Tapestry distribution and needs to be made-up of the majority of search.php, but excluding any of the html/* includes...

Cheers,
David.

Submitted by cmentgp on Wed, 2008-07-09 18:34

Hi David,

yes..i have created the searchcode.php

<?php
  if (file_exists("html/user_searchresults_before.php")) require("html/user_searchresults_before.php");
?>
<div class='searchresults'>
  <table width='100%'>
    <?php foreach($searchresults["products"] as $product): ?>
      <tr>
        <td>
          <?php if ($product["image_url"]): ?>
          <a href='<?php print $product["productHREF"]; ?>'><img border='0' width='80' src='<?php print $product["image_url"]; ?>' alt='<?php print $product["name"]; ?>' /></a>
          <?php endif; ?>
        </td>
        <td width='50'>&nbsp;</td>
        <td valign='middle'>
          <?php if ($config_useInteraction): ?>
          <h4><a href='<?php print $product["productHREF"]; ?>'><?php print $product["name"]; ?></a> <?php if ($product["rating"]) print tapestry_stars($product["rating"],""); ?></h4>
          <?php else: ?>
          <h4><a href='<?php print $product["productHREF"]; ?>'><?php print $product["name"]; ?></a></h4>
          <?php endif; ?>
          <p><?php print substr($product["description"],0,250); ?></p>
        </td>
        <td width='50'>&nbsp;</td>
        <td valign='middle' align='center'>
          <?php if ($product["numMerchants"] > 1): ?>
            <em><?php print translate("from"); ?></em>&nbsp;<strong><?php print $config_currencyHTML.$product["minPrice"]; ?></strong><br />
            <span class='nobr'><a href='<?php print $product["productHREF"]; ?>'><?php print translate("Compare Prices"); ?></a></span>
          <?php else: ?>
            <strong><?php print $config_currencyHTML.$product["price"]; ?></strong><br />
            <span class='nobr'><a href='<?php print $product["productHREF"]; ?>'><?php print translate("More Information"); ?></a></span>
          <?php endif; ?>
        </td>
      </tr>
    <?php endforeach; ?>
  </table>

Thanks again for your help and very quick responses.

Cheers :-)

Submitted by cmentgp on Wed, 2008-07-09 18:35

David....i am not getting an errors....just a blank page....no results are displaying.

Cheers

Submitted by support on Thu, 2008-07-10 11:47

Hi,

The code posted above is html/searchresults.php. Could you perhaps email me your searchcode.php and i'll check that it all looks OK....reply to your registration code or forum registration email is the easiest way to get me...

Cheers,
David.