1

I'm trying since hours to get my custom layout handle to work. I have a cms page that calls the layout handle "cms_page_view". Now I want to set in my custom module a new layout handle:

config.xml

<page>
    <layouts>
        <cms_page_view module="page">
            <label>My Page</label>
            <template>page/mypage.phtml</template>
            <layout_handle>cms_page_mypage</layout_handle>
        </cms_page_view>
    </layouts>
</page>

<frontend>
    <layout>
        <updates>
            <custom_mymodule>
                <file>custom/mypage.xml</file>
            </custom_mymodule>
        </updates>
    </layout>
</frontend>

In my new layout file (custom/mypage.xml):

<?xml version="1.0"?>
<layout>
    <cms_page_mypage translate="label">
        <label>MyPage</label>
        <reference name="root">
            <action method="setTemplate">
                <template>page/mypage.phtml</template>
            </action>
            <action method="setIsHandle">
                <applied>1</applied>
            </action>
        </reference>
        <block type="page/html_head" name="head_mypage" as="head_mypage">
            <action method="addItem"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
            <action method="addItem"><type>skin_css</type><name>css/styles-ie8.css</name><params/><if>lt IE 9</if></action>
            <action method="addCss"><stylesheet>css/widgets.css</stylesheet></action>
            <action method="addCss"><stylesheet>css/print.css</stylesheet><params>media="print"</params></action>
        </block>
    </cms_page_mypage>
</layout>

In my cms page in the backend I wrote this in the conent area:

{{block type="core/template" name="my_page" as="content" template="page/html/my_page.phtml"}}

And in the end ... nothing happens when I call my page/mypage.phtml with this content:

<head>
    <?php echo $this->getChildHtml('head_mypage') ?>
</head>

What am I missing here???

  • instead of 'head_mypage' you call 'my_page' – Magento 2 Nov 17 '15 at 14:33
  • Hi Tipo, did you manage to figure this out? Can you share your solution with us? – 7ochem Dec 17 '15 at 10:45
1

Try putting your "head_mypage" block declaration inside of <reference name="root">

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.