2

How do you add a class to a pre existing xml block?

Example:

<container name="alert.urls" as="alert_urls" label="Alert Urls" after="product.price.tier"/>
            <block class="Magento\Catalog\Block\Product\View" name="product.info" template="product/view/form.phtml" after="alert.urls">
</container>
  • This question is unclear as to wether you are asking about adding a htmlClass to a block or container please clarify, as the responses assume block, if so you should edit the title to use the word "block" instead of container – Joel Davey Oct 6 '18 at 18:52
11

Recently I've had the need for the exact same function. I decided to look at the core XML files, and found the following code to work:

<referenceBlock name="product.info" htmlClass="yourClassName canUseMutipleNames" />

I found the above code in the core file at this location:

/vendor/magento/module-theme/view/frontend/layout/default.xml

You can use this file as a reference and find some other useful tags like htmlTag :)

0

I have found some code in Magento XML core file

Please Try this code:

container name = "container_name" label="form" htmlTag="div" htmlClass="old-class" after='-'

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.