Search code examples
magentophplayout-xml

Magento - render phtml template file from layout update xml


I'm putting together my first Magento theme. Wee.

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).

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
  • 2 - save page-content as a CMS page

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.

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:

<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.

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.

Any advice or explanations would be grand.

Cheers -

b[]x


Solution

  • 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.