With the last article of Layout XML, it seems that you haven’t fully known how the system receives this layout file. Thus, please keep following the Layout and CMS post today to learn the way to register layout XML files and how to use it in CMS (content management system) in Magento. It will be helpful for your configuration operations.

1. Register Layout XML files

The code paragraph below is used to declare a layout file for both frontend and backend.

<layout>
	<updates>
		<module_name>
			<file>your_layout_file_name.xml</file>//(Ex:  module_name.xml)
		</ module_name >
	</updates>
</layout>

 

  • To declare layout file in frontend, you can put this code paragraph into tag <frontend>
  • To declare layout file in backend, you can put this code paragraph into tag <adminhtml>

System will read this configuration and load the layout file to get layout configuration for rendering page.

2. Create and add the code to pages

  • Steps to create a CMS page:

– Login Back-end

– Select menu CMS/Pages

– Click on “Add New Page” button to create a new page

– In “page information” Tab, fill in the page’s information including Page title, Page Url Key, Store view, Status

+ Page title will be used to show the title of the page

+ Page Url Key: is the Url typed in the browser to display the page which has been created

+ Store View: the limitation of displaying page. If choosing “All Store views”, the page will be displayed in every store view

+ Status: shows whether the page is enabled or not. The page will only be displayed in frontend if the status is set as “enable”

– After that, choose“Content” Tab to enter the displayed text of the page

+ Content Heading: is shown in the header of the page

+ Enter the content to display in the text area

– Choose “Design” Tab in order to select 1column, 2 columns-right and 2 columns-left or 3 columns for the page’s layout

– And then, click on “Save page” button to save

-In frontend, to access to the page, you can use the following URL: http://domain.com/cms-pages-test (cms-pages-test is CMS page’s url key)

  • Add the code to pages

There are 2 ways to add the code to the pages:  Directly add to Content in “Content” Tab or Add to Layout Update XML in “Design” Tab.

– To add the code to the content, it’s possible to use the code paragraph below:

{{block type="banner/default" name="banner.banner" template="banner/banner.phtml" alias="home_top_banner"}}

-To add the code to Layout Update XML in “Design” Tab, you can use the code as same as the way to declare in the layout file:

<reference name= “content”>
	<block type= “bannerslider/bannerslider” template= “bannerslider/bannerslider.phtml”/>
</reference>

Well, this part ends here. Don’t hesitate to leave comments if you have any concerns. I’m very willing to answer you.

See you in the next posts! 😉

Author

Why Magestore? We believe in building a meaningful & long-term relationship with you.

2 Comments

  1. Would just following all articles on this blog help me pass the certification? Do I need to go through any more books, resources?

    • Hello Joan,
      To be well-prepared for Magento certificate exam, I think besides following all posts on your blog, you should read other books about Mangento (you can search them on the Internet). Moreover, it’s great if you can read more about the code of specific areas that exam covers according to Magento guide.
      Hope you succeed!

Write A Comment