【问题标题】:Magento custom templateMagento 自定义模板
【发布时间】:2012-03-17 09:51:45
【问题描述】:

我为我的主页制作了一个自定义模板。我创建了以下文件:
1.app/etc/modules/Test_Layout.xml

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

2。 app/code/local/Test/Layout/etc/config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Test_Layout>
      <version>0.1.0</version>
    </Test_Layout>
  </modules>
<global>  
 <page>
   <layouts>
    <test_layout translate="label">
      <label>Test Layout</label>
      <template>page/home.phtml</template>
      <layout_handle>page_home</layout_handle>
    </test_layout>
   </layouts>
  </page>
</global>
</config>

3。 app/etc/modules/Mage-All.xml 并在那里添加我的模块。
4.这些东西之后,我的新模块在sys->config->advanced->advanced的列表中,
5.然后我设置CMS->Pages->Design->Custom Layout->Test Layout & Custom Theme->defualt/test(结果出现在drop-下列表。)

6.除了这些,我还设置了自定义布局/page.xml:

<block type="page/html" name="root" output="toHtml" template="page/home.phtml">

(我不确定类型
结果:Magento 使用我的自定义 page.xml,但它使用我的自定义模板“template/home.phtml”并使用其默认模板。
你能帮帮我吗?--Thx

【问题讨论】:

标签: magento


【解决方案1】:

app/code/local/Artlantis/Page/config.xml 中创建config.xml

<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
    <Artlantis_Page>
    <version>0.1.0</version>
    </Artlantis_Page>
</modules>
<global>
    <page>
    <layouts>
        <custom_cms module="page" translate="label">
        <label>Custom Home Page</label>
        <template>page/custom-home.phtml</template>
        <layout_handle>custom_home_page</layout_handle>
        </custom_cms>
    </layouts>
    </page>
</global>
</config>

app/etc/modules/Artlantis_page.xml 中创建Artlantis_Page.xml 文件

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

在 CMS 页面中,选择 Custom Design 选项卡,您将在那里看到您的布局,选择它。

【讨论】:

  • 我已经完成了这些,我对这些部分没有任何问题。当我在自定义设计中选择新布局时,Magento 不使用这个新模板!有什么帮助吗?
  • 你检查我的代码了吗?您的代码有所不同。试试我的方法,你会看到不同。忘记你的错误代码。
  • 玛莎,我不可能在整个开发过程中一直使用这种技术。也许,我在代码中做了语法错误,但这个概念是正确的。具体来说,您应该注意目录。
  • 另外,您应该在模板/页面目录中创建custom-home.phtml,而不是在/template 目录中。
  • Oğuz 感谢您的关注。我是Magento的初学者,我会再次检查并告诉你结果。但是现在我是新年假期,所以可能需要一些时间。:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-20
  • 2013-04-06
  • 1970-01-01
  • 1970-01-01
  • 2014-02-10
相关资源
最近更新 更多