0

I added a second footer block with links by adding the following code to my default.xml in my theme: app/design/frontend///Magento_Theme/layout/default.xml

<referenceContainer name="footer">
    <block class="Magento\Framework\View\Element\Html\Links" name="footer_links_custom">
        <arguments>
            <argument name="css_class" xsi:type="string">footer links</argument>
        </arguments>
    </block>
</referenceContainer>

<referenceBlock name="footer_links_custom">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="2custom-link">
        <arguments>
            <argument name="label" xsi:type="string">Custom Links</argument>
            <argument name="path" xsi:type="string">page-url</argument>
        </arguments>
    </block>
</referenceBlock>

What is the easiest way to add a title to the my footer_links_custom block, is there any way to do this in a simple manner? I've tried setting an argument "title" but that didn't work obviously. Is there any way we can know all the attributes there are for a certain block? (css_class, label, path, ...) Is there no .phtml file for the footer links block?

Magento 2 leaves me behind with a lot of questions...Thanks for the help!

2 Answers 2

0

You can add container div, css class using below code.

If you want to give title of block you need to add a phtml file as shown in below code:

       <referenceContainer name="footer">
            <container name="cms_footer_links_cs_container" title="CMS Footer Links" htmlTag="div" htmlClass="links">
            <block class="Magento\Theme\Block\Html\Footer" name="footer_link_title" template="html/customlinkfooter.phtml"/>
            <block class="Magento\Framework\View\Element\Html\Links" name="footer_links_custom">
                <arguments>
                    <argument name="css_class" xsi:type="string">footer links</argument>
                </arguments>
            </block>
            </container>
        </referenceContainer>

        <referenceBlock name="footer_links_custom">
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="2custom-link">
                <arguments>
                    <argument name="label" xsi:type="string">Custom Links</argument>
                    <argument name="path" xsi:type="string">page-url</argument>
                </arguments>
            </block>
        </referenceBlock>

Create file add title in app/design/frontend/Magento_Themecustom/templates/html/linkfooter.phtml

<div>
    <span><?php echo "Custom Links"; ?></span>
</div>
0

If you want to display Title to Footer Block, Go to Content->Blocks in admin,create a new block. Create a new div and call the block in default layout file of theme.

<referenceContainer name="footer-container">

<container name="footer.title.block" as="footer-title" label="Footer Title" htmlTag="div" htmlClass="footertitle">
<block class="Magento\Cms\Block\Block" name="footertitle" as="footertitle">
        <arguments>
          <argument name="block_id"xsi:type="string">footertitle</argument>
        </arguments>
</block>
<container>
<container name="footer" as="footer" label="Page Footer" htmlTag="div" htmlClass="footer content">
<block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="Magento_Store::switch/stores.phtml"/>
<block class="Magento\Framework\View\Element\Html\Links" name="footer_links">
<arguments>
<argument name="css_class" xsi:type="string">footer links</argument>
</arguments>
</block>
<block class="Magento\Theme\Block\Html\Footer" name="copyright" template="Magento_Theme::html/copyright.phtml"/>

</container>
</referenceContainer>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.