Post by eventHandler » Thu Oct 21, 2010 9:59 am

I'm trying to edit category.tpl so that rather than getting a list of subcategories followed by a list of products, I instead show each subcategory as a heading under which only the products in that subcategory show up. In other words, say I have a category (Books) with two subcategories (Paperback & Hardcover). I want the Book category page to look like this:

Paperback
(all the products in the paperback subcategory)

Hardcover
(all the products in the hardcover subcategory)

I tried editing category.tpl so that the $products loop was within the $category loop, but that just ended up displaying *all* the products in the Books (top level) category under a heading for each subcategory. Here is the code I used:

Code: Select all

<?php if ($categories) { ?>
    
      <?php for ($i = 0; $i < sizeof($categories); $i = $i + 4) { ?>
      
        <?php for ($j = $i; $j < ($i + 4); $j++) { ?>
        <?php if (isset($categories[$j])) { ?>
          <h3><?php echo $categories[$j]['name']; ?></h3>
          <?php for ($y = 0; $y < sizeof($products); $y = $y + 4) { ?>
      
      <div class="list">

        <?php for ($z = $y; $z < ($y + 4); $z++) { ?>
        <div class="product"><?php if (isset($products[$z])) { ?>
      <a href="<?php echo str_replace('&', '&', $products[$z]['href']); ?>"><img src="<?php echo $products[$z]['thumb']; ?>" title="<?php echo $products[$z]['name']; ?>" alt="<?php echo $products[$z]['name']; ?>" /></a>
      <span class="product_title"><a href="<?php echo str_replace('&', '&', $products[$z]['href']); ?>"><?php echo $products[$z]['name']; ?></a></span>

      <?php } ?></div>
        <?php } ?>
      <?php } ?>
          <?php } ?>
        <?php } ?>   
      <?php } ?>
    <?php } ?>
How do I edit that so that it knows I want just the $products associated with the current subcategory, rather than all the products? Do I need to also make changes in controller/product/category.php?

Thanks!

Newbie

Posts

Joined
Thu Sep 09, 2010 7:42 am

Post by kliMa » Wed Jan 05, 2011 8:52 am

Hi there,

I'm looking for the same way of display products, did you find a solution ?

New member

Posts

Joined
Sat May 08, 2010 2:24 am
Location - London
Who is online

Users browsing this forum: No registered users and 11 guests