1

I'm attempting to create a custom page layout for a Magento site I'm building, but having the most difficult time in the world getting the template to actually appear in the dropdown menu when I create a page. I've tried repeatedly, using different sources, to get this to work, and have no idea where to go from here.

The most annoying part of this is that it works just fine on my local copy of Magento. When I move the exact same code to my remote hosting, however, it no longer shows up in the list.

Here's an example of one of the layouts I've tried to create:

/app/code/local/custom/layouts/etc/config.xml:

<?xml version="1.0"?>
<config>
     <modules>
        <custom_layouts>
            <version>0.1.0</version>
        </custom_layouts>
     </modules>
     <global>
        <page>
            <layouts>
                <home_page_layout module="page" translate="label">
                 <label>Home Page Layout</label>
                 <template>page/home-layout.phtml</template>
                </home_page_layout>
           </layouts>
        </page>
    </global>
</config>

/app/etc/modules/custom_layouts.xml:

<?xml version="1.0"?>
<config>
 <modules>
  <custom_layouts>
   <codePool>local</codePool>
   <active>true</active>
  </custom_layouts>
 </modules>
</config>

/app/design/frontend/THEME/default/template/page/home-layout.phtml:

CODE...

Any idea why this might not be properly appearing? I've double checked to see if the theme is correctly set in Magento too, but that didn't affect anything (obviously).

  • Where is your /app/design/frontend/THEME/default/layout/layouts.xml – amit_game Aug 7 '15 at 4:30
  • I don't have a layouts.xml created anywhere that I know of, but I did find a custom_layout.xml in /app/design/frontend/THEME/default/layout that's just sitting there -- possibly from when I was trying to get this up a long time ago. Do I need a layouts.xml? Thanks! – Alex MacArthur Aug 7 '15 at 4:41
1

You need to two things to get the layout

First : You need to add layout_handle for your layout

<global>
    <page>
        <layouts>
            <home_page_layout module="page" translate="label">
             <label>Home Page Layout</label>
             <template>page/home-layout.phtml</template>
             <layout_handle>home_page</layout_handle> <!--You need to add this-->
            </home_page_layout>
       </layouts>
    </page>
</global>

Second : Need to add the handle in your local.xml or your layout file

<home_page translate="label">
    <label>Home page layout</label>
    <reference name="root">
        <action method="setTemplate"><template>page/home-layout.phtml</template></action>
        <!-- Mark root page block that template is applied -->
        <action method="setIsHandle"><applied>1</applied></action>
        <action method="setLayoutCode"><name>home_page_layout</name></action>
    </reference>
</home_page>

Refer this Link

| improve this answer | |
  • That doesn't seem to be working. I've added the layout handle and placed that block of code in my custom_layout.xml file (in app/design/frontend/THEME/default/layout), and flushed the cache, but the page has still not appeared. I'm so confused why this would be working on my local machine but not on my hosting when it's the exact same code. – Alex MacArthur Aug 7 '15 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.