2

I have a container defined in a layout file, but in some case with help of other xml I would like to change its htmlClass value, is it possible by override or something ? or need to create new container for this?

1

You can change the htmlClass in theme level

For example get the layout into your theme and modify it.

I grab the code from module-theme, kept in Luma theme and added my htmlclass(mycustomclass).

<referenceContainer name="header.container">
    <container name="header.panel.wrapper" htmlClass="panel wrapper" htmlTag="div" before="-">
        <container name="header.panel" label="Page Header Panel" htmlTag="div" htmlClass="panel header **mycustomclass**">
            <block class="Magento\Framework\View\Element\Template" name="skip_to_content" template="Magento_Theme::html/skip.phtml">
                <arguments>
                    <argument name="target" xsi:type="string">contentarea</argument>
                    <argument name="label" translate="true" xsi:type="string">Skip to Content</argument>
                </arguments>
            </block>
            <block class="Magento\Store\Block\Switcher" name="store_language" as="store_language" template="switch/languages.phtml"/>
            <block class="Magento\Framework\View\Element\Html\Links" name="top.links">
                <arguments>
                    <argument name="css_class" xsi:type="string">header links</argument>
                </arguments>
            </block>
        </container>
    </container>
  • Thanks Krishna, Its worked, but I cannot use <container name="main.content" not sure whats the issue, the contents are empty while use "main.content" named container – Riyas Muhammed Sep 21 '16 at 11:58
  • @ Riyas Muhammed Feel free to ask new question with code you have tried. – Krishna ijjada Sep 21 '16 at 12:36

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.