Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: Location of function renderCategoriesMenuHtml found in top.phtml

The top navigation template file at /catalogue/navigation/top.phtml contains just this short function:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
        <?php echo $_menu ?>   
        </ul>
</div>
<?php endif ?>

I'm trying to find the renderCategoriesMenuHtml function so that I can get in and edit the structure of the $_menu result that is called in top.phtml.

The purpose is that I want to slightly edit the structure the menu. It currently comes out in a ul > li > a > ul > li > a > span in HTML and I want to edit this slightly.

like image 402
James Avatar asked Nov 29 '22 14:11

James


2 Answers

The command

$ grep -i -r 'function renderCategoriesMenuHtml' *

returns

app/code/core/Mage/Catalog/Block/Navigation.php

which contains

public function renderCategoriesMenuHtml($level = 0, $outermostItemClass = '', $childrenWrapClass = '')
...
like image 110
Alan Storm Avatar answered Dec 05 '22 21:12

Alan Storm


as an alternative, for those who aren't so familiar with grep, this file also have a PHPDoc comment:

<?php
/**
 * Top menu for store
 *
 * @see Mage_Catalog_Block_Navigation
 */
?>

As you can see, it says which class $this is refering to in this file, in which you'll find the method you're looking for.

HTH

like image 20
OSdave Avatar answered Dec 05 '22 21:12

OSdave