Add link to top menu using xml magento -
i try add custom link top menu using xml didn't work.i used code before , work fine stuck it.my xml code :
<default> <reference name="top.links"> <block type="articles/links" name="articles"/> <action method="addlinkblock" ><blockname>articles</blockname></action> </reference> <reference name="footer_links"> <block type="articles/links" name="articles"/> <action method="addlinkblock"><blockname>articles</blockname></action> </reference> </default>
and block code :
class my_articles_block_links extends mage_core_block_template { protected function _tohtml() { $html =''; if(mage::helper('articles')->getarticlesenable()){ if(in_array(mage::app()->getstore()->getstoreid(),mage::helper('articles')->getscopeid())){ $html.= '<li><a href="'.mage::helper('articles')->geturl().'">articles</a></li>'; return $html; } } return $html; } }.
the block code fine , tested.only issue xml code.thanks in advance.
as have action tag check function in action addactionlayouthandles()
so, instead of overidding _tohtml()
add function
function addlinkblock(){ $parentblock = $this->getparentblock(); $parentblock->addlink('whatever link want add'); }
Comments
Post a Comment