Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

How do I add a block to the home page only above the content section, but below the navigation to spread across the page whilst still using the two-column template?

I am using Magento version 1.9.

See image:

Enter image description here

share|improve this question

3 Answers 3

You don't need to create a module at all. You can use Widgets in Magento 1.4+:

Click on CMS > Widgets:

enter image description here

Click on "Add a new Widget Instance":

enter image description here

Select "CMS Static Block" and the name of your theme:

enter image description here

Then, under 'frontend properties' give it a title and click "Add Layout Update", and configure it as shown to display only on the home page in the main content block:

enter image description here

Under Widget Options select the static block you want to display:

enter image description here

share|improve this answer
    
+1 for screenshots –  Geek Num 88 Jul 1 at 17:23
    
This is the best of all three solutions... –  user1704524 Jul 2 at 11:11

Create local.xml under app/design/frontend/your package/your template/layout/

And Put the code

<?xml version="1.0"?>
<layout version="0.1.0">

    <cms_index_index>
        <reference name="root">
            <block type="core/template"  name="my.vblock" before="content" template="page/home/myblock.phtml" after="breadcrumbs" />
        </reference>
    </cms_index_index>
share|improve this answer
    
That is a good method... –  user1704524 Jun 30 at 16:52
    
Thank's for this! But I'm trying to do it before the breadcrumbs. I tried before="breadcurmbs" but it says the XML is invalid. How can I make this work? –  Alyssa Reyes Dec 9 at 4:04

Here's a really quick way to do it...

Create a module:

<?xml version="1.0"?>
<config>
    <modules>
        <Tamedo_PageLayout>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Page/>
            </depends>
        </Tamedo_PageLayout>
    </modules>
</config>

Then add the following to your config file

<?xml version="1.0"?>
<config>
    <modules>
        <Tamedo_PageLayout>
            <version>0.1.0</version>
        </Tamedo_PageLayout>
    </modules>
    <global>
        <page>
            <layouts>
                <homepage_layout translate="label">
                    <label>Homepage Layout</label>
                    <template>page/1column-home.phtml</template>
                </homepage_layout>
            </layouts>
        </page>
    </global>
</config>

And in your theme folder app/design/frontend/YOURTHEME/default/template/page/1column-home.phtml

add this:

<head>
    <?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
    <?php echo $this->getChildHtml('global_notices') ?>
    <div class="page">
        <?php echo $this->getChildHtml('header') ?>
**<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('custom_block')->toHtml(); ?>** 
        <div class="main-container col1-layout cms-home">
            <div class="main">
                <?php echo $this->getChildHtml('breadcrumbs') ?>
                <div class="col-main">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
            </div>
        </div>
        <?php echo $this->getChildHtml('footer_before') ?>
        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('global_cookie_notice') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>
    </div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>

Then in your Magento admin create a static block called 'custom_block' or whatever and add it to 1column-home.phtml after the header:

<?php echo $this->getChildHtml('header') ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('custom_block')->toHtml(); ?>

Be sure to add some content to the static block and select your new homepage layout from the design tab in CMS pages...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.