You are here:  » Related / Featured same format?


Related / Featured same format?

Submitted by philstone on Sat, 2006-09-02 11:03 in

Dave

maybe not the easiest question

how would you format the related products the same way as the featured products?

Regards

phil

Submitted by support on Sat, 2006-09-02 11:45

Hi Phil,

As it happens, I produced a HTML module for displaying search results in blocks rather than a list earlier today! Save the code below as /html/related.php. It works as a direct replacement for html/searchresults.php, so you can then edit your page that shows related products and use require("html/related.php"); in place of require("html/searchresults.php");

html/related.php

<div class='searchresults'>
  <table width='100%'>
    <tr>
      <?php $counter 0; foreach($searchresults["products"] as $product): ?>
        <?php
          if ($counter == 3)
          {
            print "</tr>";
            print "<tr>";
            $counter = 0;
          }
          $counter++;
        ?>
        <td width='33%' align='center'>
        <table>
        <tr>
        <td valign='middle' align='center'>
          <?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; ?>
        </td>
        </tr>
        <tr>
        <td valign='middle' align='center'>
          <?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>
        </tr>
        <tr>
        <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>
        </table>
        </td>
        <?php endforeach; ?>
     </tr>
  </table>
</div>

Cheers,
David.

Submitted by chiquita on Mon, 2006-10-02 21:19

Which are the pages that show related products?

Submitted by support on Mon, 2006-10-02 21:29

Hi,

Related Products can be displayed on the individual product pages. This is now part of the distribution - if you have the latest version set:

$config_useRelated = true;

...in config.php. If you don't, you can get the files from the latest distribution. If you have modified your installation already you can just add html/related.php to your installation, then merge the changes from products.php.

Cheers,
David.