简体   繁体   English

Magento-从布局更新XML渲染phtml模板文件

[英]Magento - render phtml template file from layout update xml

I'm putting together my first Magento theme. 我正在整理我的第一个Magento主题。 Wee. e

This site will have a large number of static pages, and I'm trying to determine the best method of getting that content into the system in an easily maintainable way. 这个站点将有大量的静态页面,我正在尝试确定以易于维护的方式将这些内容输入系统的最佳方法。 Ideally, this process can be managed by a team member with limited experience in magento (this is a key point). 理想情况下,此过程可以由在magento方面经验有限的团队成员来管理(这是关键点)。

Aside from these two main methods of including static "page" content: 除了包括静态“页面”内容的这两种主要方法之外:

  • 1 - save page-content as a CMS static block, to be added to a category page 1-将page-content另存为CMS静态块,以添加到类别页面
  • 2 - save page-content as a CMS page 2-将page-content另存为CMS页面

it seems I should be able to just render a phtml template file (with page-content as real markup) from a combination of layout update xml directives (in a cms page / category page), or as a widget type of include. 看来我应该能够从布局更新xml指令(在cms页/类别页中)的组合中呈现phtml模板文件(以page-content作为真实标记),或作为包含的小部件类型。

Assuming my file structure looks like this: 假设我的文件结构如下所示:

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

I've tried planting this file into a cms page via a number of variations on: 我尝试通过以下多种方法将此文件植入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>

in the layout update xml. 在布局更新xml中。

Alternatively, I've tried to render this file via content directives like: 另外,我尝试通过内容指令来呈现此文件,例如:

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

With (obviously) no luck so far. 到目前为止(显然)没有运气。

Granted - there maybe reasons not to deal with static content in this way, but it may still be a viable alternative to the two steps already mentioned (image and link pathing, for example). 当然-也许有理由不以这种方式处理静态内容,但是对于已经提到的两个步骤(例如,图像和链接路径),它仍然是可行的选择。

At any rate - I believe some combination of update xml or content directives should be workable, but I'm still getting my head around Magento layout and haven't figured out the correct method. 无论如何-我认为可以将update xml或content指令组合使用,但我仍会继续关注Magento布局,但尚未找到正确的方法。

Any advice or explanations would be grand. 任何建议或解释都是宏大的。

Cheers - 干杯-

b[]x b [] x

For any future overflowers looking to figure this out: 对于希望找出这一点的任何将来的溢出者:

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

works for sure. 可以肯定的。 Just tried it this morning without the name attribute and viola. 今天早上刚刚尝试过,没有名称属性和中提琴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM