0

I've made a custom theme and custom homepage layout that renders a custom container and inside it a block with a custom template:

custom_homepage.xml inside Magento_Theme/page_layout folder

    <?xml version="1.0"?>
    <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
        <update handle="empty" />
        <referenceContainer name="page.wrapper">
            <!-- <container name="header.container" as="header_container" label="Page Header Container"  htmlTag="header" htmlClass="page-header" before="main.content"/> -->
            <container name="page.top" as="page_top" label="After Page Header" after="header.container"/>
            <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer" />


           <!-- MY CUSTOM CONTAINER AND BLOCK WITH CUSTOM TEMPLATE -->
            <container name="custom.container" as="customContainer" label="Custom Container" htmlTag="div" htmlClass="custom-container">
                <block class="Magento\Framework\View\Element\Template" name="testing" type="cms/block" template="Magento_Theme::test.phtml" />
            </container>
        </referenceContainer>
    </layout>

I also have a layouts.xml which is:

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">

    <layout id="custom_homepage">
        <label translate="true">Custom Homepage</label>
    </layout>
</page_layouts>

So in my admin section I can go to content -> pages -> and set this layout as custom homepage. Everything renders and I get the text from test.phtml inside Magento_Theme/templates which is:

<h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem suscipit, adipisci, cum quos, alias similique ad eum at deserunt eligendi enim dignissimos, unde vero ipsam voluptatibus cumque accusantium! Obcaecati, quasi.</h2>

Now I want to go and add another block to my custom container from above as widget from admin panel.. So I go to admin/content/widget/new widget and under 'Add Layout Update' I select Page Layout and under Page tab I do not see my custom homepage here, neither 1 column, 2 columns with right bar and other made by default..

Also under container tab I do not see my label (Custom Container), only the default ones like (Page Footer Container, After Page Header, etc..)

What am I doing wrong?

Thanks!

  • You should read more here: magento.stackexchange.com/questions/139950/… – Khoa TruongDinh Oct 10 '16 at 13:30
  • @KhoaTruongDinh Hey man thanks for helping but this is not what I had in mind. The link you gave me says how to customize a page by editor and this is very limited.. For example I'd like to create products list container and from admin I'd like to add product as widget.. How would I do that? Basically, how do I add ANY widget to my custom layout? – Marko Niciforovic Oct 10 '16 at 13:41
  • You want to add the widget product via Admin? – Khoa TruongDinh Oct 10 '16 at 13:47
  • Yes, to custom container that I created in my custom_homepage.xml.. – Marko Niciforovic Oct 10 '16 at 13:48
  • Hei, did you get this working? Am looking for the exact same thing. – Gerard Lamusse Oct 3 '17 at 7:11
0

add your container to default.xml than select in your widget config: Display on * Specified Page

and your container should be visible in dropdown

| improve this answer | |

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.