0

I want to display the output of a template on my homepage. It is meant to display the first level categories in my shop. What I have below isn't rendering. May I ask what I'm missing?

{{block type="core/template" template="catalog/navigation/subcategory_listing.phtml" category_id="category/3"}}

PHTML File Below:

<?php
$_categories = $this->getCurrentChildCategories ();
$_helper = $this->helper ( 'catalog/output' );
?>

<div class="listing-type-list catalog-listing">

    <?php

    foreach ( $_categories as $_category ):
        ?>

        <?php if ( $_category->getIsActive () ): ?>
        <?php
        if ( $_category->getListingName () )
        {
            $name = $_category->getListingName ();
        }
        else
        {
            $name = $_category->getName ();
        }
        $_category = Mage :: getModel ( 'catalog/category' ) ->load ( $_category ->getId () );
        ?>

        <div class="listing-item">

            <?php if ( $_category->getImageUrl () ): ?>

                <div class="product-image col-md-4">

                    <a href="<?php echo $_category->getURL () ?>" title="<?php echo $this->htmlEscape ( $name ) ?>"><img src="<?php echo $_category->getImageUrl () ?>" width="205" alt="<?php echo $this->htmlEscape ( $name ) ?>"/></a>

                    <?php else: ?>

                    <?php endif; ?>

                    <div class="product-cagetory-title"><a href="<?php echo $_category->getURL () ?>" title="<?php echo $this->htmlEscape ( $name ) ?>"><?php echo $this->htmlEscape ( $name ) ?></a></div>

                </div><!-- end col md 4 -->

        </div><!-- end listing item -->

    <?php endif; ?>

    <?php endforeach; ?>

</div><!-- end catalog listing -->
  • Can you poste some code of your .phtml – Klettseb Mar 26 '15 at 12:36
  • are you getting into the template at all? – David Manners Mar 26 '15 at 12:46
  • Nothing renders if thats what you mean. – Matthew McLennan Mar 26 '15 at 12:46
  • @MattMcLennan if you put a die on the first line do you get that far? – David Manners Mar 26 '15 at 12:47
3

I am going to guess the problem is that there is no function getCurrentChildCategories on the block type core/template. What you could look into doing is making your own block with this function, the function itself can be found in Mage_Catalog_Block_Navigation

Or you could simply get the category you have set against the block and load the children from the category object.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.