将自定义PHTML模板添加到Magento CMS页面

时间:2016-10-21 16:20:13

标签: magento

我刚刚学习Magento,所以,我刚刚在youtube上讨论了如何创建自定义模板。一切都很顺利,直到我不得不将<codePool>更改为本地。

使用默认的<codePool>core</codePool>我可以看到我创建的新模板(重复1column.phtml并更改了名称)但不是我的更改,因为而不是1column显示3列布局。如果我将<codePool>更改为本地<codePool>local</codePool>,我会看到一个没有任何内容的白页。

这些是我所做的步骤。谁可以帮我这个事?我正在使用Magento ver。 1.9.2.4。感谢。

-------------添加一个自定义模板------------------- https://www.youtube.com/watch?v=144V9aSmhZc

  1. 转到: 应用程序/设计/前端/默认/主题你 - 是 - 使用/模板/页/

    然后复制其中一个模板。

  2. 然后去: 应用程序/代码/本地/

    并创建dir结构: /法师/页的/ etc /

    最后应该是这样的: 应用程序/代码/本地/法师/页的/ etc /

  3. 现在去: 应用程序/核心/法师/页的/ etc / config.xml中

    并将其复制到:

    应用程序/代码/本地/法师/页的/ etc /

  4. 打开'config.xml'并转到<layout>部分并添加更改,例如

    <reward-points module="page" translate="label">
     <label>Reward Points</label>
     <template>page/rewards.phtml</template>
     <layout_handle>page_rewards</layout_handle>
    </reward-points>
    
  5. 之后,打开: 应用程序的/ etc /模块/ Mage_All.xml

    转到并更改为“本地”,所以它看起来像这样:

    <codePool>local</codePool>
    
  6. 现在,转到系统/缓存管理和'刷新Magento缓存'

  7. 转到CMS /页面,单击任意页面,然后单击左侧的“设计”选项卡。现在,“布局”下拉列表应显示新布局。

1 个答案:

答案 0 :(得分:0)

在本地复制核心文件会给你带来结果,但这样做不会包括升级后的核心方法。所以你可以通过注册你的模块来添加自定义的phtml模板

  

应用程序的/ etc /模块

 <?xml version="1.0"?>
  <config>
     <modules>
           <Custom_Pagelayout>
                 <codePool>local</codePool>
                 <active>true</active>
          </Custom_Pagelayout>
     </modules>
</config>

现在在本地创建模块的文件夹结构。

  

定制/页面布局/等

添加config.xml

<?xml version="1.0"?>
<config>
 <global>
      <page>
           <layouts>
                <custom_phtml_file>
                     <label>Custom phtml</label>
                     <template>page/custom.phtml</template>
                </custom_phtml_file>
       </layouts>
      </page>
 </global>
</config>

然后在主题中添加custom.phtml。

相关问题