1

For my custom module i need to add one top-menu to homepage. Path may change according to the value given in configuration section. How can i add dynamic link to the top-menu item.Please help

2
  • you want to add something to the top menu, the one that contains the categories, or the top links, the one with "My account"?
    – Marius
    Commented Jul 2, 2014 at 6:26
  • Near "My Account" I wish to add one menu named "News".The path of this menu may change with path given in the adminpanel configuration settings section.
    – Anu
    Commented Jul 2, 2014 at 7:06

1 Answer 1

4

Here is an example on how you can add dynamic links to the top menu: https://magento.stackexchange.com/a/18947/146.
In the example above the languages are added to the top links, but you can modify your block to include any language.
All you need to change is: Easylife_Locale_Block_Stores::addStoreLinks and make it look like this:

public function addStoreLinks() {
    $parentBlock = $this->getParentBlock();
    if ($parentBlock) {
        $position = 200; //start position
        $newsLinkPath = Mage::getStoreConfig('path/to/value_here');
        $newsLink = Mage::getUrl('', array('_direct'=>$newsLinkPath));
        $title = $this->__('News');
        $text = $title;
        $parentBlock->addLink($text, $newsLink, $title, false, array(), $position);
    }
    return $this;
}

Feel free to rename your method as you want just make sure you change its name in the layout file also.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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