1

I have just designed a website for a client and i need your help with Magento's main navigation. Just to clarify i mean the navigation menu which shows 1st level categories once added which is horizontal in the header file, not the top links.

I need to move this nav into a div in the home page content if possible. I cant use the left sidebar to do so because the main content will wrap underneath the navigation as well as the rest of the page. How would i do this?

I can mess around with the CSS in order to get it in a vertical list, but its just getting the navigation into the main content first!

Thanks

1
  • Question does you specifically mention the home page do you only need to move it on home or on all pages? Commented Jan 24, 2014 at 20:26

2 Answers 2

3

I would suggest using unsetChild and insert rather than remove and then having to create the block again. Oddly unsetChild takes the block alias set via as but insert takes the block name.

<default>
    <reference name="header">
        <action method="unsetChild"><name>topMenu</name></action>
    </reference>
    <reference name="content">
        <action method="insert"><name>top.menu</name></action>
    </reference>
</default>

Using insert also gives you some more power as regards to positioning of the block etc as you can pass some more parameters.

public function insert($block, $siblingName = '', $after = false, $alias = '')

NOTE: the main functions you can use via layout xml can be found in Mage_Core_Block_Abstract

0

Using your layout's local.xml, you want to do something like this:

<default>                   
<reference name="header">
    <remove name="top.menu" />
</reference>            
<reference name="left">
        <block type="core/text_list" name="left.menu" before="-" translate="label">
            <label>Navigation Bar</label>
            <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
        </block>
</reference>

Remove the top.menu block from the header and add it to the left. Of course it can go into the main if you don't want to use the left. The code is just an example of how this can be done - not meant to be an exact copy and paste.

Code with my edit worked for me:

enter image description here

5
  • Hi ben, thanks for your answer. Unfortunately the first reference to remove the top.menu isnt working, i have cleared the cash and var file but no success, any ideas why? Also i would like the top menu to be in my main content not the left sidebar, so is there a way i could do that? thanks
    – Tom Burman
    Commented Jan 24, 2014 at 19:23
  • I found out why the top nav wasnt being removed so i take it back your code did work. i still have the issue of trying to get the nav in the main content of the home page? thanks
    – Tom Burman
    Commented Jan 24, 2014 at 19:26
  • I typed that out from memory, maybe my edit will be closer
    – Ben Truby
    Commented Jan 24, 2014 at 19:49
  • You should also make sure the page you are looking at has the left col. If you are in a one page layout, it won't have left.
    – Ben Truby
    Commented Jan 24, 2014 at 19:51
  • Yup, my edited code works for me.
    – Ben Truby
    Commented Jan 24, 2014 at 19:55

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.