|
Bill...excellent initiative ! I wish this post already existed when I started with magento… you wouldn’t believe the time I spend on simple stuff ....
Here is my tip : combining the top links or adding a new one .
I spend some time trying to do this but didn’t get to it because I never fully understand how it’s done.
You can see that you have on your page.xml , on the default handler something like this:
<block type="page/html_header" name="header" as="header"> <block type="page/html_toplinks" name="top.left.links" as="topLeftLinks"/> <block type="page/html_toplinks" name="top.right.links" as="topRightLinks"/> <block type="core/text_list" name="top.menu" as="topMenu"/> </block>
So there we have the header block and we are including on it two other blocks; top.left.links and top.right.links .
The important thing here is that those blocks are referenced in other xml layouts, such as in catalog.xml or checkout.xml , where the links are actually made . I had a lot of trouble finding/understanding where it was actually made
This is in checkout.xml for example :
<reference name="top.right.links"> <block type="checkout/links" name="checkout_cart_link"> <action method="addCartLink"></action> </block> <block type="checkout/links" name="checkout_link"> <action method="addCheckoutLink"></action> </block> </reference>
So you see that there is an action called, with a method “addCheckoutLink” . Hm..wander what that does , right?
And you see that both blocks are in reference name “top.right.links “
If you want to merge the menus together, you should rename the reference on all the correspondent layouts (say catalog.xml , checkout.xml, etc...) from top.left.links and top.right.links to something like “top.links” or whatever you like.
So the first piece of code (the one on page.xml ) should be now
<block type="page/html_header" name="header" as="header"> <block type="page/html_toplinks" name="top.links" as="topLinks"> </block> <block type="core/text_list" name="top.menu" as="topMenu"> </block> </block>
You see that one block is gone, because we are merging both.
And this changes on layout pages such as catalog.xml, or chekout.xml (this example)
<reference name="top.links"> <block type="checkout/links" name="checkout_cart_link"> <action method="addCartLink"></action> </block> <block type="checkout/links" name="checkout_link"> <action method="addCheckoutLink"></action> </block> </reference> <reference name="right"> <block type="checkout/cart_sidebar" name="cart_sidebar" before="-" template="checkout/cart/sidebar.phtml"/> </reference>
now, adding a link :
if you look at the code above you’ll see that the link is done with <action method="something"> ; there is a method called “addLink” , wich does.....a link, obviously .
<block type="page/html_toplinks" name="top.links" as="topLinks"> <action method="addLink"><li/><a>href="{{baseUrl}}your/link/here"</a><label> Home </label></action> </block>
the {{baseUrl}} thing adds your site path.
Hope this helps...thanks to all the people that help me get to this!
|