【问题标题】:Magento - render phtml template file from layout update xmlMagento - 从布局更新 xml 渲染 phtml 模板文件
【发布时间】:2012-03-08 02:20:08
【问题描述】:

我正在整理我的第一个 Magento 主题。小。

该站点将包含大量静态页面,我正在尝试确定以易于维护的方式将该内容放入系统的最佳方法。理想情况下,这个过程可以由一个在 magento 方面经验有限的团队成员来管理(这是一个关键点)。

除了这两种包含静态“页面”内容的主要方法:

  • 1 - 将 page-content 保存为 CMS 静态块,添加到 分类页面
  • 2 - 将 page-content 保存为 CMS 页面

似乎我应该能够通过布局更新 xml 指令的组合(在 cms 页面/类别页面中)或作为包含的小部件类型来呈现一个 phtml 模板文件(page-content 作为真正的标记) .

假设我的文件结构如下:

/my_theme
     /default
     /varient
          /template
               /cms
                    /template
                         /category1
                              /category2
                                   - page_content.phtml

我已尝试通过以下多种变体将此文件植入 cms 页面:

<reference name="content">
     <block type="core/template" name="content.current" as="content.current" output="toHtml" template="cms/template/category1/category2/page_content.phtml"
</reference>

在布局更新xml中。

或者,我尝试通过以下内容指令呈现此文件:

{{block type="core/template" name="content.current" template="cms/template/category1/category2/page_content.phtml"}}

到目前为止(显然)没有运气。

当然 - 可能有理由不以这种方式处理静态内容,但它可能仍然是已经提到的两个步骤(例如图像和链接路径)的可行替代方案。

无论如何 - 我相信一些更新 xml 或内容指令的组合应该是可行的,但我仍然对 Magento 布局有所了解,还没有找到正确的方法。

任何建议或解释都会很重要。

干杯-

b[]x

【问题讨论】:

  • 与其做你在上面做的,为什么不使用默认的洋红色主题结构呢?你知道,/app/design/frontend/default/yourtheme/layout 和 ../template?以你的方式做事有什么意义?
  • 没有。我正在使用标准主题结构。我说的只是 cms 内容。

标签: magento php layout-xml


【解决方案1】:

对于任何希望解决这个问题的未来溢出者:

{{block type='core/template' template='cms/template/category1/category2/page_content.phtml'}}

确实有效。今天早上刚试了一下,没有name属性和viola。

【讨论】:

    猜你喜欢
    • 2015-10-11
    • 2012-05-30
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多