How do i add layout to the homepage of my site
-
05-01-2021 - |
Question
How do I add a layout to the homepage of my site? The homepage content is NOT a full screen and id like to add a full-width banner with a clickable button on it just like what we have here on this site
However, I tried using the static block for this but it didn't work. I am new to Magento and would really appreciate all the help I can get.
La solution
How do I add a layout to the homepage of my site?
Suggestion: There is defaults layout which Magento provides which can be easily changed for a page from the backend.
http://magebase.com/magento-tutorials/demystifying-magentos-layout-xml-part-1/
- To insert a cms Block directly:
{{block type="cms/block" block_id="your_block_id"}}
You can use widgets for the same
- In the Editor toolbar, click on insert Widget
- Choose Static Block
- Choose the Block you want to insert
In the widget, we can easily call our blocks in the different reference which are created:
Autres conseils
in order to create custom layout for Magento 1.x cms pages you have to create a custom module:
Module directory / file(s) structure :
app/etc/modules/Home_PageFullwidth.xml
app/code/local/Home/PageFullwidth/etc/config.xml
app/design/frontend/{Theme-Vendor/{Theme-name}/page/home-page.phtml
app/etc/modules/Home_PageFullwidth.xml
<?xml version="1.0"?><config>
<modules>
<Home_PageFullwidth>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Page />
</depends>
</Home_PageFullwidth>
</modules>
app/code/local/Home/PageFullwidth/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Home_PageFullwidth>
<version>0.1.0</version>
</Home_PageFullwidth>
</modules>
<global>
<page>
<layouts>
<PageFullwidth translate="label">
<label>1Column-fullWidth</label>
<template>page/home-page.phtml</template>
<layout_handle>homepage_fullwidth</layout_handle>
</PageFullwidth>
</layouts>
</page>
</global>
</config>
And finally your template file page/home-page.phtml:
<!DOCTYPE html>
<html lang="<?php echo $this->getLang() ?>">
<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('custom_notice') ?>
<?php echo $this->getChildHtml('header') ?>
<?php echo $this->getChildHtml('topContainer') ?>
<div class="main-container col1-layout">
<div class="main">
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?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>