1

How to create a footer link in custom theme and how to set path to that link ?

I have created custom feedback module which contains form for feedback.

Now I need to set link in custom theme and want to set path for the link.

The path should refer from my feedback module** Please help me

=> Custom Module:layout file

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>
            Sample
        </title>
    </head>
    <body>
       <referenceContainer name="footer">
            <block class="Magento\Framework\View\Element\Template" template="X_Y::form.phtml"/>
        </referenceContainer>

    </body>
</page>

form.phtml

<div>
    <a id="feedback">Feedback</a>
.....
....
....
</div>

While clicking link it will show a popup. So here I have mentioned id, Now I have declared my link in custom theme, But How do I specify this id in link

  • If you have any query then feel free to ask me. – Rohan Hapani Jan 8 '18 at 4:53
  • If I added this in my custom theme then what is the need of my layout file in custom module – Jaisa Jan 8 '18 at 5:05
  • You need to add footer links so you must need to add in custom theme. In custom module, layout file used for your controller action. Do not remove that file from custom module. – Rohan Hapani Jan 8 '18 at 5:13
  • @Rohan Hapani Please the the updated post and solve my issue – Jaisa Jan 8 '18 at 5:37
  • This answer already working. Where's problem occured? – Rohan Hapani Jan 8 '18 at 5:51
1

app/design/frontend/CustomName/customtheme/Magento_Theme/layout :

<?xml version="1.0"?>
<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="default_head_blocks"/>
<body>

<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="custom-page">
<arguments>
<argument name="label" xsi:type="string">Title of your page</argument>
<argument name="path" xsi:type="string">url-key-of-your-page</argument>
</arguments>
</block>
</referenceBlock>

</body>
</page>

Create your default.xml on this above path and try it. It will works.

1

To add new links to footer links, use this code in <Vendor>\theme>\Magento_Theme\layout\default.xml

<referenceBlock name="footer_links">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="your-link-name">
        <arguments>
            <argument name="label" xsi:type="string">Title</argument>
            <argument name="path" xsi:type="string">path-of-your-page</argument>
        </arguments>
    </block>
</referenceBlock>
  • Shall I add default.xml file in my custom module instead of custom theme – Jaisa Jan 8 '18 at 4:46
  • No. You can add it in your custom theme. – Kishan Patadia Jan 8 '18 at 4:55
  • If I added this link in custom theme then What is the need of my layout file (Which consists only a link) in custom module ?? Am I need to remove layout file ? – Jaisa Jan 8 '18 at 5:03
  • No. Then you can add it in your custom module. In this case no need to use custom theme. – Kishan Patadia Jan 8 '18 at 5:21

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