0

I created a custom landing page module for our store.

app/code/<Company>/Landing

It has the following directory structure, but I am having a really hard time figuring out how to integrate it into the overall site.

enter image description here

For example, how am I supposed to apply a theme to the pages served by this module?

Most importantly though, how do I modify the layout of this page? I have tried using the <referenceBlock name="name" remove="true"/> pattern but cannot figure out where to put. A lot of posts mention default.xml, but where would I locate this file in the directory structure?

enter image description here For example, I want to remove these templates from the page. It would seem that they are located in the <referenceContainer name="header.container"> tag, so I have tried adding: <referenceContainer name="header.container" remove="true"> tag but to no avail.

1

You can create your own default.xml and put it in app/code/<Company>/Landing/view/frontend/layout like this.

enter image description here

Any update in default.xml will affect all your frontend pages. E.g., you want to remove header.container from all pages. Your default.xml can be like this.

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header.container" remove="true" />
    </body>
</page>

UPDATE: You totally can do it with specific page, by create xml file for specific request. E.g., To add static css file for checkout/cart/index page, create checkout_cart_index.xml in app/code/<Company>/Landing/view/frontend/layout.

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="path/to/css-file.css" />
    </head>
    <body>
        <referenceContainer name="header.container" remove="true" />
    </body>
</page>

Hope it helps.

3
  • Ahh I see, so I can't do it page specific in that case. What I've decided to try doing is to serve static CSS to this page only which will turn off the display attribute for all of those HTML elements... Dec 11 '17 at 5:29
  • 1
    @DanielThompson please see my updated answer
    – Quan Le
    Dec 11 '17 at 6:07
  • very helpful, thank you! Didn't realize you could do that with layout files. Dec 11 '17 at 6:30

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.