Is it possible to update or change a theme layout so that all default files would remain unchanged, yet all changes you make would be listed in a single file?Also, is it possible to optimize the working process in such a way so that you would not need to search for multiple changes in the template files? One would say that this is impossible, however the solution lies in the local.xml file.
Mаgentо defines visual structure and behavior of each page block via the tag <block>. As we know, in Mаgentо there are 2 types of blocks: structural and content. Both of them can be defined by the element <block>.
So, what is the <block> element?
<Block> - This element is used to define a new block. The element is usually defined within the
referenceelement, when we want to create a new block. The
blockelement must have two attributes:
type. The first one is a unique identifier of the block in the layout while the second one defines the block class name. If the block is of type or subtype of
core/template, it can also have the
templateattribute which defines the actual phtml template file to be used for rendering the block.
What are Layout files in Magento?
As you might already know, the View in Magento (stands for the View from MVC pattern) is more difficult than in most PHP applications and it contains not only Templates – html/css/js code with PHP or any other template engine (such as Smarty, Twig etc.), but also Blocks which are basically PHP objects. In classical MVC a controller sends commands to its associated view to change the view’s presentation of the model. Instead, the View component, Block calls Models to get the necessary information to provide it to the Template file. But how Magento defines which Blocks objects should be instantiated in the specific page ($this)? All this is defined in Layouts.
By using Magento layout files you can quickly enable, disable or move almost all of Magento’s content and functional blocks. The Layout files are XML files that defines which Blocks are included on a page, and which Block(s) should start the rendering process. It can be very frustrating and confusing at first, but when you get used to it, you can handle your themes in a very upgrade-compatible way, because Layout is the tool which helps to assign content blocks to each structural block you create easily.
What is Magento design fallback?
Fallback mechanism in Magento is the ability of Magento to use the files from multiple themes in one page, i.e. making your own custom themes more upgradable and with fewer files.
Magento has used fallback mechanism since the very beginning, however from Magento CE 1.4 and Magento EE 1.8 they added base/default theme as the final step of the fallback mechanism.
The fallback mechanism looks like this:
As everyone knows Magento is a MVC application and we will be tackling it’s V letter a.k.a View in this series of articles.
Magento’s View layer is a tricky one and contains Blocks, Layouts and Templates, but for Magento Front End Developer certification we need to study Layouts and Templates only in form of Themes. But how does a typical Magento theme look like and how can we create one?
Theme is grouped together templating files (PHTML, XML, CSV) and/or skin files (CSS, JS files and images) that create the visual representation of your store, splitted between two main directores – app/design and skin. If you open these folders you’d see that both have three folders – adminhtml (what you see when you’re logged in Magento admin area), frontend (what your customers see) and install (what you see during Magento installation). More information can be found in my post for Magento Developer Certification – The Main Magento Design Areas and More… We’re interested in ‘frontend’ folder and inside app/design/frontend and skin/frontend you also can see two folders – base and default (enterprise for Magento Enterprise edition) and they’re Packages.