![](/img/trans.png)
[英]Magento Layot XML - Change template for 2columns-left.phtml
[英]Magento - injecting custom phtml block into 2columns-left.phtml not working
在我的local.xml文件中,我有標記來覆蓋產品目錄頁面。 在面包屑之前的2columns-left.phtml內部,我想創建具有動態產品類別標題,描述和背景顏色(取決於類別名稱)的自定義類別塊。
問題是我的自定義塊沒有出現。 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>
樣板/頁面/html/head/big_header.phtml:
<h1>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</h1>
當我將此塊添加到: <reference name="head">
big_header.phtml內容正常顯示。
我使用Magento 1.7
如下所示在主題布局文件夾中創建local.xml。
<?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>
將模板創建為
您的主題名稱=>模板文件夾=>頁面文件夾=> html文件夾=>頭文件夾=>和big_header.phtml文件
我認為“樣板”是您的主題名稱。
確保要檢查的類別頁面在管理區域中已將Page Layout set to "No layout updates"
。
目錄=>管理類別=>從左側邊欄中選擇類別=>轉到自定義設計選項卡和頁面布局字段。
無需使用$this->getChildHtml('big_header')
;
Magento使用core/text_list
塊(例如content
)將自動呈現所有子元素。 Unforutnatley, root
不是其中之一。 您需要編輯模板page/2columns-left.phtml
並為您的代碼塊添加一個調用-即
<?php echo $this->getChildHtml('big_header') ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.