1

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!

2 Answers 2

2

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">

1
  • Thanks, that worked. I still haven't figured out when to use ie. layout or local.xml, but I've opened a new question for that.
    – Frank
    Jan 24, 2015 at 19:14
0

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.

1
  • I know that, but how do I place slider.phtml using local.xml?
    – Frank
    Jan 23, 2015 at 21:01

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.