2 Comments

Magento Container not working in custom layout

Stop Magento from changing image paths / names when Flush Catalog Images Cache?
How can I get Visual Swatch option imange in magento 2 product view page

I have created a custom XML layout page that I will be using for my home page. Right now it is a clone of the normal 1column.xml layout, and I’m trying to add a container for an image slider.

Here is the code I have added to my layout file (home_page.xml):

<container name="slider.container" htmlTag="div" htmlId="slider.container" htmlClass="slider-container" before="page.top"/>

This should in theory produce the following HTML code on the home page:

<div class="slider-container" id="slider.container"> </div>

However, absolutely nothing is happening. I cannot find the container when inspecting all of the elements on the page with the F12 console. I have also added some test CCS to “slider-container” just to be sure, and absolutely nothing is showing.

My custom XML layout page should be working fine. If I remove the footer or header container from the layout file, and flush the cache, they disappear from the page as they should. This tells me that everything is set up and working correctly, but something isn’t working correctly within the file.

Related Posts

  • Magento2 Add Login/Logout Button homepage (1)
    I have a home landing page that has a Login/Logout button. It's currently static html, but I'm trying to convert it so that the button actually functions same as default login/logout button. I tried creating a custom template landing-content.phtml and updating my Layout Update XML […]
  • How to change item on Magento cart/checkout page (0)
    I'm trying to add an item description to my Magento checkout page. I want the description to be under the Item title, inside the table that contains the items. I'm using my own module to add the description in, but I can't find any way that works for me. I've searched and have only […]
  • Custom Magento Block failing silently from CMS page (0)
    Another just when I thought I was getting the hang of Magento issue. Trying to build a module, Got what I considered to be the tricky bit out the way and now I am having a nightmare trying to get a block to appear on the frontend. Under Update Layout xml on the cms […]
  • Layout Update XML doesn't properly work for the home page (4)
    I'm using magento 2 and I'm trying to add this code <reference name="head"> <action method="addItem"> <type>skin_js</type><script>jsfilename.js</script> </action> </reference> into my Layout Update XML, but for some reason, my […]
  • Inserting Javascript codes in one CMS page of Magento 2.1 (1)
    I am trying to add some javascript codes in one CMS page of a Magento 2.1 site. Here are what I did and the issues I am facing now: 1)at the "Layout Update XML" of the page, add the following jquery codes which will be used further: The relevant Javacript codes come in the form […]
  • Magento 2: Creating a custom layout (1)
    I'm having trouble creating a custom layout. I have successfully created a layout called home_page.xml which is a copy of the default 1column layout. I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the […]
  • Using secured frontend, some links are serving HTTPS, other are not (2)
    A clients store has a SSL certificate set up and the option to use a secure frontend is enabled. This means the site can be used on both HTTP and HTTPS. However, when accessing the site securely, some links on the home page for example are HTTPS and other aren't. E.g. I have two […]
  • Magento 2 – Checkout – Payment methods not visible (1)
    I'm trying to extend checkout page, I copied the checkout_index_index.xml in my layout folder (vendor/theme/Magento_Checkout/layout) I change some thing in the file, now in the payment method I can't find method I set on the admin page. If I remove my custom layout file, the […]
  • Layout XML – Custom Layout Update not being used (1)
    I have set a layout update for a category in the admin (Custom Layout Update). Here is the code incase that is not legible <reference name="product_list"> <action […]
  • Reverting block rewrite, how to set all child block elements (1)
    I had a custom page where I had to rewrite page/page.phtml, and inside the template file I needed some methods. So I had to rewrite the base class Mage_Page_Block_Html. This is how my module's layout xml look liked: <vendorpage_index_index> <reference […]
Stop Magento from changing image paths / names when Flush Catalog Images Cache?
How can I get Visual Swatch option imange in magento 2 product view page

2 Comments on this article

  • User November 12, 2016

    clear cache and page_cachemay help you fix this problem

    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
    </head>
    <body>
        <referenceContainer name="content">  
            <container name="slider.container" htmlTag="div" htmlId="slider.container" htmlClass="slider-container" before="">
                <block class="VendorModuleBlockExampleBlock" name="block.slider" as="slider.cms" template="Vendor_MOdule::yourblocktemplate.phtml" after="-" />
            </container>
        </referenceContainer>
    </body>
    

    Reply

  • User November 12, 2016

    The main problem is: <div class="slider-container" id="slider.container"></div>
    did not rendered when it have not any child element in it.
    You must set block in this container. Ex:

    <container name="slider.container" htmlTag="div" htmlId="slider.container" htmlClass="slider-container" before="page.top">
         <block class="MagentoFrameworkViewElementTemplate" after="-" name="abc" template="PATH_YOUR_TEMPLATE" />
    </container>
    

    Or you can use <move> element with destination is ‘slider.container’ (name of container) to have child element in it.

    Reply

Add a comment