Add a new block to local.xml
Question
I'm kinda new to front-end magento, and this is probably asked alot, but I can't figure it out.
I'm trying to add a slider to my homepage, just below the header and just before the content starts.
I figured the best way to do this is by edditing local.xml (right?)
<cms_index_index>
<reference name="root">
<block type="core/template" name="slider" after="header" template="page/index/slider.phtml" before="-" />
</reference>
</cms_index_index>
page/index/slider.phtml echo's a test, which unfortunately doesn't show up. Does anyone know what I'm doing wrong? Thanks in advance!
Solution
In layout:
<cms_index_index>
<reference name="content">
<block type="core/template" name="slider" template="page/index/slider.phtml" before="-" />
</reference>
</cms_index_index>
In Admin panel: CMS -> Pages, select your current home page and add
{{block type="core/template" template="page/index/slider.phtml"}}
In the beginning of the page.
Pay attention to <reference name="
content">
OTHER TIPS
You could use XML to place a block on the homepage above the content and below the header, and yes all XML edits should go into YOUR_PACKAGE/YOUR_THEME/layout/local.xml. Since you've created your own template path (YOUR_PACKAGE/YOUR_THEME/template/page/index/slider.phtml) and I assume that all the slider code is in that slider.phtml file you can also call that file directly in your CMS homepage.
Open the admin and go to CMS -> Pages. Click on the page that you want to add the slider to. Click on the Content tab and insert the following code:
{{block type="core/template" template="page/index/slider.phtml"}}
This is an easy way to call .phtml files from CMS pages or Static Blocks.