Magento – Adding title to cms footer block

footermagento2

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!

Best Answer

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>
Related Topic