Magento Template System

E-mail Print PDF

The template system in Magento is pretty controversial. The choice of using regular PHP for the templating language has caught some criticism froma fewusers. But, the choice of regular PHPhas notmade the templating system simple or under-powered, not by a long shot. This has to be the most flexible and advanced templating system that this author has ever seen (in PHP).

A complete page is rendered as a nested set of magento template files (technically, a nested set of Blocks). There are no explicit “widgets” in the system, that means, you won’t find a specific “Form” class nor “Button” class or object. The lowly Block classes straddle the line between widgets and templates. The nested set of templates and blocks is controlled by... you guessed it, an XML file, specifically a set of XML files. This is quite powerful for developers and plug-in contributors, but it seems that it is overly complicated for most designers (even those familiar with PHP et al.).


Layout Files The layout files control the structure of any final page rendering. They are located in the layout folder under your design theme. There are a number of XML files whose names loosely relate to an individual module, but they are all lower-case letters, whereas the module names traditionally use the so-called camel-case method. The most important XML file is page.xml.

app/design/frontend/default/default/layout/
...
page.xml
catalogsearch.xml
catalog.xml
checkout.xml
cms.xml
contacts.xml
...

The page.xml file specifies the default page structure. All modifications from any of the other XML files are modifications of settings under the default XML tag. The following is a list of tags that are common to all layout files.

Sometimes you will see tags like the following. These tags are layout handles, they behave like the default tag, but only during certain requests. These tags follow a pattern that relates to the module, controller, and action of the given Web request. If the tag only has two parts, separated by an underscore, like cms_page, then these settings are applied to all requests to that module and controller.

Testimonials

Professional design, easy installation, free support, thank you!!!Smile

--- Warren

Quick reply and download the template very fast, hope to see more.

--- La D'vine

I purchased this template Medical Equipment PrestaShop Theme 53790, Awesome template, real masterpiece! Mobile-friendly, all the content is clear!

--- Todd Cluff

The experience of buying on your site is so good. Will buy again.

--- Jesus Teran

Excellent website templates, keep updating.Laughing

--- Bakery

 
You are here: Magento Tutorial Magento Template System