Thứ Tư, 25 tháng 11, 2015


You have seen that the layout files in Magento control the presence or absence of each content block in a theme. What, specifically, gets rendered inside of that block is controlled by the template files. Most
templates do not contain any logic about whether they will or will not be rendered—remember that’s
typically handled by the layout files. Once a template is called, it is expected that it will be parsed and displayed.

Template files in Magento are PHTML files that contain xHTML and PHP that will be parsed and then rendered by the browser. Once you identify which template file is being used to generate the contents of a specific block, you can modify that template file if desired. Or you can modify the layout file to associate a different template file with a block, which allows you to create completely new template files.

As a general recommendation, rather than editing Magento’s template files, it is a better practice to copy a template file that you want to alter to your theme with a slightly different name and to edit that newly renamed file. Then you would update the layout to reflect that it should use your new template for that block. That preserves the original Magento template in case it is used in multiple places and ensures that when the Magento application is upgraded any changes to the original template file won’t impact your modified template without your explicit review.

Building on the previous example of using a local.xml file to override layout declarations, if you wanted your category pages to have a unique page template, you might want to create a new page template in app/design/frontend/<your_package>/default/template/page/ named “2columns-custom.phtml.” In it you perhaps create a modified version of Magento’s two-column with a left sidebar page template to also include new structural blocks for cross prom otions and free shippi ng messages that you only want to appear on the category pages.


0 nhận xét :

Đăng nhận xét

Design by NewWpThemes