0

I trying to add the categories of my store in the header, for this I do these steps:

On page.xml, add this block categories:

<block type="page/html_header" name="header" as="header">
      <block type="core/template" name="top.categories" as="topCategories" template="catalog/navigation/categories.phtml" />
      ...
</block>

Create the categories.phtml, on catalog/navigation/, with this code:

<?php $_menu = $this->renderCategoriesMenuHtml(1,'level-top') ?>
<?php if($_menu): ?>
<nav class="left-nav">
    <ul class="nav-list">
        <?php echo $_menu ?>
    </ul>
</nav>
<?php endif ?>

And call this block in header, with the code:

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

But, whe I call this, return a error:

a:5:{i:0;s:111:"Invalid method Mage_Core_Block_Template::renderCategoriesMenuHtml(Array ( [0] => 1 [1] => level-top ) )";i:1;s:3818:"#0 [internal function]: Varien_Object->__call('renderCategorie...', Array)

I'm using Magento 1.6.2.

What am I doing wrong?

4

1 回答 1

2

The block that you are calling with categories.phtml should implement renderCategoriesMenuHtml method, that should return menu items. You are using core/template block, which doesn't have such method (and shouldn't). You have to use correct block type, that implements getting categories html.

Try to use catalog/navigation instead of core/template.

于 2013-04-17T12:41:24.737 回答