1

this is my layout xml:

<catalog_category_default translate="label">
        <label>Catalog Category (Non-Anchor)</label>
        <reference name="content">
            <block type="core/template" name="page.brand" template="page/brand.phtml" />
            <block type="catalog/product_list" template="page/accessories.phtml">
                 <block type="catalog/navigation" name="catalog.leftnav" as="filter_menu" template="catalog/navigation/left.phtml"/> 
            </block>
        </reference>
</catalog_category_default>

And from within page.accessories.phtml, inside some div block i call:

<?php echo $this->getChildHtml('filter_menu') ?>

but nothing renders out. Why is that?

this is code from the layered phtml file:

<div class="oh_shit"></div>
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
    <div class="block-title">
        <strong><span><?php echo $this->__('Shop By') ?></span></strong>
    </div>
    <div class="block-content">
        <?php echo $this->getStateHtml() ?>
        <?php if ($this->getLayer()->getState()->getFilters()): ?>
            <div class="actions"><a href="<?php echo $this->getClearUrl() ?>"><?php echo $this->__('Clear All') ?></a></div>
        <?php endif; ?>
        <?php if($this->canShowOptions()): ?>
            <p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
            <dl id="narrow-by-list">
                <?php $_filters = $this->getFilters() ?>
                <?php foreach ($_filters as $_filter): ?>
                <?php if($_filter->getItemsCount()): ?>
                    <dt><?php echo $this->__($_filter->getName()) ?></dt>
                    <dd><?php echo $_filter->getHtml() ?></dd>
                <?php endif; ?>
                <?php endforeach; ?>
            </dl>
            <script type="text/javascript">decorateDataList('narrow-by-list')</script>
        <?php endif; ?>
    </div>
</div>
<?php endif; ?>
Masu
  • 1,568
  • 4
  • 20
  • 41

2 Answers2

1

Try adding your blocks in your layout xml to:

<catalog_category_layered translate="label">
    <label>Catalog Category</label>
    <reference name="content">
        <block type="core/template" name="page.brand" template="page/brand.phtml" />
        <block type="catalog/product_list" template="page/accessories.phtml">
             <block type="catalog/navigation" name="catalog.leftnav" as="filter_menu" template="catalog/navigation/left.phtml"/> 
        </block>
    </reference>
</catalog_category_layered>
seanbreeden
  • 6,104
  • 5
  • 36
  • 45
  • sorry, i hadn't included the layered xml change in my post but i changed that as well. its identical to the default layout as well. it should be rendering shouldn't it? – Masu Nov 03 '13 at 18:45
  • 1
    ok it works. i had noticed that it is outputting the gethtml but inside the phtml it has a couple of if clauses, and it turns out for some reason that the if is returning false so it wasnt outputting anything. i put a temporary div block outside the if and it was creating the div block. Thank you for your help! – Masu Nov 03 '13 at 18:55
  • it looks like canShowBlock is returning false, any idea why – Masu Nov 03 '13 at 18:56
  • How are you referencing canShowBlock? Can you post the code? – seanbreeden Nov 03 '13 at 18:59
  • ok i edited my post, it is exactly the same as the original, i haven't changed anything other than the layout xml files. – Masu Nov 03 '13 at 19:01
  • looks like i spoke too soon, it looks like getchildhtml wasnt being called at all. i had been outputting the block in the reference block as well as putting it in the nested block. so i was printing the blocks both times only the nested one wasnt being printed. no idea why its not working. – Masu Nov 03 '13 at 19:08
  • after debugging it looks like the getchild on the product_list block object is returning false. there is no child, only a "toolbar" child, does this have to do with the type that catalog/navigation and catalog/product_list don't interact? – Masu Nov 03 '13 at 20:13
1

ok. i got it. i accidentally deleted the name attribute on the block with type="product_list". when i re-added the name="product_list" it worked.

Masu
  • 1,568
  • 4
  • 20
  • 41
  • I had the same problem, figured out that without a name Magento could not set the parent block. See: http://www.schmengler-se.de/en/2014/09/magento-layout-getchildhtml-mit-leerem-ergebnis/ – Fabian Schmengler Sep 05 '14 at 12:51