发大水 范德萨
Making a new page layout or template with Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.
Making a new page layout or template with
Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be
Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.
Making a new page layout or template with Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.
Making a new page layout or template with Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.
Making a new page layout or template with
Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be
Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.
Making a new page layout or template with Magento is kind of a tricky task. Magento comes standard with a 3column, 2column-right, 2coulmn-left, 1coulmn, and a empty layout but what if you wanted to create a 4column or maybe just create a custom template for your pages or even just certain pages. Well in order to do this you first need to understand how Magento works. First you have your .phtml files. These are basically your template files but to make these file do anything you have to get into the .xml files and tell them where to go. This is something that really no one can just tell you how to do it you actually have to either get into the filing system and experiment or buy a book. A good book to start with would be Magento User Guide.
Creating The Template File
In you are new to Magento then this will be kind of fun for you. First you need to create your .phtml file. In order to do that you need to navigate to your themes template pages folder. How to find that? Well if you are using the default Magento theme then you would first go to app -> frontend -> default -> default -> template -> page inside of there you will need to create you template file. So let say we want to create a 4coulmn template. You would just add a 4columns.phtml or whatever you would like to call it. Now you may be thinking you are all done. Nope if you go into your Magento Admin Panel or Dashboard and go under cms pages. You will see that you can not select your new template as a layout. Well this is because you need to first tell the Magento xml file to use the template.
Editing The XML
Lets locate those xml files. If you are still in the template -> page directory then all you have to do is go out one directory to layout. If you are not in the directory anymore you will have to navigate to app -> frountend -> default -> default -> layout. Inside this directory you are going to be looking for the page.xml file. Open it and navigate to the bottom. You should find some code like this
<!-- Custom page layout handles -->
<page_empty translate="label">
<label>All Empty Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/empty.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_empty>
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
<page_two_columns_right translate="label">
<label>All Two-Column Layout Pages (Right Column)</label>
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_right>
<page_three_columns translate="label">
<label>All Three-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_three_columns> |
Now you need to add your page template to the end of the page.xml file. So you would do something like this.
<page_four_column translate="label">
<label>Four Column Page Layout</label>
<reference name="root">
<action method="setTemplate"><template>page/4columns.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_four_column> |
Once you have added that you should be good to go. If you do not see the layout in the drop down in the cms page area, you may need to refresh your Magento cache. To do this go the Magento Admin Panel or Dashboard and go to System->Cache Management. Refresh all the cache. If that does not work then you need to go back and make sure you have named everything correct.