You are here:  » <p> being created in searchresults loop


<p> being created in searchresults loop

Submitted by Harvey on Sat, 2008-12-20 14:01 in

Hi David,

A bizarre one - for every product there is on a page, there's a new paragraph at the top. For example - http://www.featuredbrands.co.uk/gant-clothing/gant-shirts/

- if you go on a post with less products, there will be less spaces.

IE doesn't produce the spaces, Firefox/Chrome do.

And I can't see them when viewing the source code, or indeed in the loop!

Code that goes in a post:

<?php
    
if (is_single() || is_page()) {
  
// now preload $_GET["q"] to be the query you want to display search results for
  
$_GET["q"] = "brand:query";
  
// now bring in the search code
  
require(ABSPATH'/shop/searchcode.php');
  
// now use Price Tapestry's search results HTML module to display the results
  
require(ABSPATH'/shop/html/searchresults.php');
}
?>

Searchresults.php

<?php
  $columns = 3;
  $currentColumn = 0;
?>
<div class='searchresults'>
  <table width='100%' cellpadding="5">
    <tr>
    <?php foreach($searchresults["products"] as $product): ?>
    <?php
    if ($currentColumn == $columns)
    {
      print "</tr>";
      print "<tr>";
      $currentColumn = 0;
    }
    $currentColumn++;
    ?>
       <td valign='top'> <!-- RESULT -->
        <table>
          <tr>
            <td align='center'>
              <?php if ($config_useInteraction): ?>
              <h4><a href='<?php print $product["productHREF"]; ?>'><?php print substr($product["name"],0,strrpos($product["name"]," ")); ?></a><br /><?php if ($product["rating"]) print tapestry_stars($product["rating"],""); ?></h4>
              <?php else: ?>
              <h4><a href='<?php print $product["productHREF"]; ?>'><?php print substr($product["name"],0,strrpos($product["name"]," ")); ?></a></h4>
              <?php endif; ?>
            </td>
          </tr>
          <tr>
            <td align='center'>
              <?php if ($product["image_url"]): ?>
              <a href='<?php print $product["productHREF"]; ?>'><img style='border: 1px solid #DE0174;' src='<?php print $product["image_url"]; ?>' alt='<?php print substr($product["name"],0,strrpos($product["name"]," ")); ?>' /></a>
              <?php endif; ?>
            </td>
          </tr>
          <tr>
            <td 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 />
              <?php endif; ?>
            </td>
          </tr>
        </table>
      </td> <!-- result -->
      <?php endforeach; ?>
    </tr>
  </table>
</div>
<?php
  if (file_exists("html/user_searchresults_after.php")) require("html/user_searchresults_after.php");
?>

I won't bother including search.php as it's pretty standard - let me know if you need any more info to work it out - many thanks!

Submitted by support on Sat, 2008-12-20 19:04

Hi Harvey,

That's bizarre - but it seems to be something to do with the comments in the code.

Try removing:

<!-- RESULT -->

...and

<!-- result -->

...and see if that clears it - I suspect it's something to do with the HTML being processed by the CMS...

Cheers,
David.