So I see that when i add new categories under the root, they dynamically populate the main navigation. Is there a way to have CMS pages also auto populate this navigation? or must I manually add or remove pages here:
the file called ‘top.phtml’ in app/design/frontend/default/default/template/catalog/navigation/ and make the following change:-
<!-- Use CMS pages in top menu --> <block type="cms/block" name="top_menu" as="topMenu"> <action method="setBlockId"><block_id>top_menu</block_id></action> </block>
Have got it working, but only when applied to a website or the default config. Does not seem to work if implemented at store level, so needs to be implemented higher up the chain.
<!– Store switcher is now in header –> <block type=”core/store_switcher” name=”store_switcher” as=”storeSwitcher” template=”core/stores.phtml”/>
<!– Use CMS pages in top menu –> <block type=”cms/block” name=”main_menu” as=”mainMenu”> <action method=”setBlockId”> <block_id>main_menu</block_id> </action> </block> </block>
Edit app/design/frontend/default/custom//cms.xml by adding to <default>:
I prefer my approach because it is easier to make changes to the menu, simply by editing the CMS block, whereas using the first method, you would have to keep finding that file in your code and making the changes there. Creating a CMS block is more consistent with the rest of Magento, and how the footer links are done.
@Moshe - You are right “it’s only templates and layouts”, but for store owners and users - who may not even know HTML - this kind of thing looks like “code hacking”.
People who use programs like Joomla expect that they can change navigation and blocks with a GUI, not by using XML configuration (layout) files and PHP/HTML template files.
For me it’s no problem, but for a lot of people this is way too much.
Can you update your code, or is it still works? I don’t seem able to get it working. The code you posted above, worked for me in v0.7x, butthe cms.xml file had changed since v0.8x, so I didn’t bother to update it and had used Matt’s method.
Now I wanted to use yours method, but I am confused with the comment in the cms.xml file:
<reference name="footer"> <block type="cms/block" name="cms_footer_links" before="footer_links"> <!-- The content of this block is taken from the database by its block_id. You can manage it in admin CMS -> Static Blocks --> <action method="setBlockId"><block_id>footer_links</block_id></action> </block> </reference>
I don’t know this is differ to which one, the block type or action method.
‘ <!-- The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
I want to add a new link to the top menu (next to My Account, My Cart, Checkout, etc.). So I created a new CMS page (via CMS-->Manage Pages). I enabled the page, set its SEF identifier, layout etc. - I can even preview it via the admin panel. However, I can’t for the life of me figure out how to make it show up on my frontend! I obviously realize that I need to manually add it “somewhere” - but where???
i tried Kharismas method and changed page.xml and cms.xml and added a static block , but I got an error message referring to
Warning: simplexml_load_string(): Entity: line 62: parser error : StartTag: invalid element name in /srv/www/.../httpdocs/app/code/core/Mage/Core/Model/Layout/Update.php on line 276 Trace:
Maybe after the latest update Kharismas code has to be modified? Has someone a solution for this?
Cheers
This has to be without a doubt the most frustrating thing I’ve tried to do so far, maybe with the exception of figuring out that you need a root category for any of your products to show. I think Magento is fantastic and very flexible but the documentation is really lacking and needs to be updated before new releases.
Anyway, this is how I did it:
1. I made copies of these files and put them in my custom theme folder so as not to overwrite the default files, ie, ’app/design/frontend/default/my_theme‘ instead of ’app/design/frontend/default/default‘. Getting a custom theme to display is another PITA.
2. I created a static block in the CMS with the id of ’top-nav‘.
3. cms.xml
I placed this inside the <default> tag (above <reference name="footer">) because I want it on every page.
Then, I directed the template file to call and display the block with <?php echo $this->getChildHtml('topNav') ?> after the top menu that displays the categories.
@Lance Monotone
Thank you so much. I have been cracking my head on my desk all day for this one. Simple when you see it, and you think that this would be in the designers guide as one of the exercises or something. Anyways, this is great.
Thanks!,
CKD
Lance Monotone - 30 May 2008 06:51 AM
This has to be without a doubt the most frustrating thing I’ve tried to do so far, maybe with the exception of figuring out that you need a root category for any of your products to show. I think Magento is fantastic and very flexible but the documentation is really lacking and needs to be updated before new releases.
Anyway, this is how I did it:
1. I made copies of these files and put them in my custom theme folder so as not to overwrite the default files, ie, ’app/design/frontend/default/my_theme‘ instead of ’app/design/frontend/default/default‘. Getting a custom theme to display is another PITA.
2. I created a static block in the CMS with the id of ’top-nav‘.
3. cms.xml
I placed this inside the <default> tag (above <reference name="footer">) because I want it on every page.
Then, I directed the template file to call and display the block with <?php echo $this->getChildHtml('topNav') ?> after the top menu that displays the categories.
This thread is very useful and I’ve managed to get it working following Lance Monotone’s instructions.
Does anyone know how to make these navigation links show <li class="active" to show when you are on a particular page?
This is seen in the top nav in the Modern theme.
thanks a lot @Lance Monotone, it works fine for me, in fact I used your tutorial to create a static block to customize the top links bar (to add small images between them )
* My Account * My Wishlist * My Cart * Checkout * Log In