In my local.xml file, i have markup to overwrite product catalog page. Inside of 2columns-left.phtml before breadcrumb i want to create custom category block with dynamic product category title, and description and background color depending on category name.
Problem is that my custom block not appearing. local.xml:
<catalog_category_view>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
<block type="core/template" name="big_header" before="content" template="boilerplate/page/html/head/big_header.phtml" />
</reference>
</catalog_category_view>
boilerplate/page/html/head/big_header.phtml:
<h1>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</h1>
When i add this block into: <reference name="head">
content from big_header.phtml appear normally.
I use Magento 1.7
Create a local.xml in your theme layout folder as below.
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_category_view>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="content">
<block type="core/template" name="big_header" before="content" template="page/html/head/big_header.phtml" />
</reference>
</catalog_category_view>
</layout>
Create templae as
Your theme name => template folder => page folder => html folder => head folder => and big_header.phtml file
I think "boilerplate" is your theme name.
Make sure the category page which you are checking is Page Layout set to "No layout updates"
in admin area.
Catalog => Manage categories => choose your category from left sidebar => go to custom design tab and Page Layout field.
There is no need to use $this->getChildHtml('big_header')
;
Magento uses core/text_list
blocks (such as content
) which will automagically render all child elements. Unforutnatley, root
is not one of these. You need to edit your template page/2columns-left.phtml
and add a call into it for your block - ie
<?php echo $this->getChildHtml('big_header') ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.