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 a 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 a widget from the 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 the 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!

Msquare
9,4627 gold badges30 silver badges71 bronze badges
asked Oct 10, 2016 at 13:20
5
  • You should read more here: magento.stackexchange.com/questions/139950/… Commented Oct 10, 2016 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? Commented Oct 10, 2016 at 13:41
  • You want to add the widget product via Admin? Commented Oct 10, 2016 at 13:47
  • Yes, to custom container that I created in my custom_homepage.xml.. Commented Oct 10, 2016 at 13:48
  • Hei, did you get this working? Am looking for the exact same thing. Commented Oct 3, 2017 at 7:11

1 Answer 1

0

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

and your container should be visible in the dropdown

Msquare
9,4627 gold badges30 silver badges71 bronze badges
answered Jun 24, 2020 at 14:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.