I am trying to add my custom div with class and id before the maincontent.
<main id="maincontent" class="page-main">
can i add the custom div before this line? How this can be done. Please anyone suggest me.
layoutmagento2
I am trying to add my custom div with class and id before the maincontent.
<main id="maincontent" class="page-main">
can i add the custom div before this line? How this can be done. Please anyone suggest me.
tag
You could try adding a new structural block and echo this out before the tag where you require.
<default>
<reference name="root">
<block type="core/text_list" name="my_before_body" as="my_before_body" translate="label">
<label>My before body</label>
</block>
</reference>
<reference name="my_before_body">
<block type="core/template" name="marketplace_player" template="magenetwork/list.phtml">
</reference>
</default>
You would then need to echo out this new structural block in your page templates before the body tag
<?php echo $this->getChildHtml('my_before_body') ?>
If you're interested, the answer is to use a referenceContainer
in the XML
file and add the new Class / ID names to the DIV
/ XML container
.
For example:
<referenceContainer name="main.content" htmlTag="main" htmlId="add-ID-name-to-container" htmlClass="new-class-name"/>
The rendered DIV (main)
will look like:
<main id="add-ID-name-to-container" class="new-class-name" >
...
</main>
The un-edited/updated version would look like:
<main id="maincontent" class="page-main" >
...
</main>
Best Answer
You can try the below code:
UPDATED ANSWER AS PER COMMENT:
Create default.xml under: