Reputation: 1389
I want to display a list of all categories on the home page as links, so when someone clicks then they go that page.
I tried something like this: I put this code on content of cms -> home page
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/view.phtml"}}
{{block type="catalog/product_list" category_id="2" template="catalog/product/list.phtml"}}
But it displays nothing.. my home page becomes blank, when I put only this:
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/view.phtml"}}
then all products are displayed correctly..
Upvotes: 1
Views: 4177
Reputation: 1
I've used the following code in the wysiwyg editor
to achieve the above
{{block type="catalog/navigation" name="catalog.category" template="catalog/product/mycatt.phtml"}}
It seems to work well.
Upvotes: 0
Reputation: 1522
Depending on where you wish to place these links, there are many ways to achieve this.
if you wish to place category links in the content of the homepage then this can be achieved easily by heading to CMS > Pages > Homepage: Design tab and adding the following to Layout update XML:
<reference name="content">
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml">
<block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
</block>
</block>
</reference>
Then you would have to style it to your liking (to avoid the duplicate menu look).
If your homepage follows a multi-column layout and you wish to add the links to one of the sidebars then this is a little more tricky.
The best way would be to create your own module here. After head to app/design/frontend/yourpackage/yourtemplate/layout/ and add the following to your xml layout:
<default>
<reference name="left">
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml">
<block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
</block>
</block>
</reference>
</default>
Depending on what layout your homepage conforms to you would replace the default tag with page_two_columns_left, page_two_columns_right, page_three_columns etc. Again you'll have to style it to your liking.
I hope this helps
Upvotes: 1