0

I am developing a new Magento 2 theme based on Magento Blank parent. I am trying to move the footer-container outside the page-wrapper container. To do so I inserted in my app/design/frontend/custom/theme/Magento_Theme/layout/default.xml the following instruction:

<move element="footer" destination="root" after="-" />

The footer content is correctly moved outside the page-wrapper container but it is not wrapped anymore in the footer tag. What I get is:

<div class="page-wrapper">...</div>
<div class="footer content">...</div>

What I expected was

<div class="page-wrapper">...</div>
<footer class="page-footer">
    <div class="footer content">...</div>
</footer>

What should I do to keep the footer tag? Should I redeclare a new container with htmlTag="footer" in my default.xml and move the footer element inside it?

1

You need to reference the container by its name not its alias. The footer element you're looking for is declared in Magento/Theme/view/frontend/page_layout/1column.xml and has a name of footer-container. Changing your layout XML to the following should fix the issue:

<move element="footer-container" destination="root" after="-" />

Right now what you're doing is moving the child element with the name footer outside of footer-container. Since the footer-container no longer has any children the <footer> doesn't get rendered and you only see the child element you moved.

  • I tried your solution, but the footer still disappears. – gianis6 Feb 7 '17 at 10:54
0

Please use this code :

<footer class="page-footer">
       <move element="footer" destination="root" after="-" />
</footer>

Instead of:

 <move element="footer" destination="root" after="-" />
  • I can't see your code – gianis6 Feb 7 '17 at 10:25
  • You can use this code. – Akshay Verma Feb 7 '17 at 10:31
  • In this way all the footer content goes away, the div with class "footer content" disappears – gianis6 Feb 7 '17 at 10:57
  • I use it inmy project & its showing after "maincontent" class – Akshay Verma Feb 7 '17 at 10:59
  • after main content section <footer> section is created inside <div class="page-wrapper">...</div> – Akshay Verma Feb 7 '17 at 11:03
0

The only thing that worked for me it has been redefining a new footer container in the default.xml file and move the footer content inside it:

<body>
    <container name="footer-container" as="footer" before="before.body.end" label="Page Footer Container" htmlTag="footer" htmlClass="page-footer"/>
    <move element="footer" destination="footer-container" before="-"/>
</body>

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.