0

I have created custom in link header,

<referenceBlock name="header.links">
    <block class="Magento\Framework\view\Element\Html\Link" name="custom-link" before="-">
        <arguments>
            <argument name="label" xsi:type="string" translate="true"> Custom Link </argument>
            <argument name="path" xsi:type="string" translate="true"> customlink </argument>             

        </arguments>
    </block>
</referenceBlock>

Move the element using

<move element="custom-link" destination="header.panel" after="logo" />

I can't able to add desgn for this link. I need to add images for this custom link and do some customization. How to achieve my task?

3
  • Can't you do it by making custom block class and template for header.links? Dec 16, 2020 at 7:42
  • can you pls guide me for this? Above is my custom link script?
    – zus
    Dec 16, 2020 at 7:43
  • Actually, I haven't done much work on this, just added a link. But I think for customization you can start from there. I'm writing a bit of code in answer for default.xml, see if that helps. Dec 16, 2020 at 7:53

1 Answer 1

1

See if below code helps.

<referenceContainer name="header.panel">
            <block class="Vendor\Module\Block\LinkArticle" name="header.links" template="Vendoe_Module::link.phtml">
                <arguments>
                    <argument name="css_class" xsi:type="string">header_links</argument>
                </arguments>
            </block>
        </referenceContainer>
8
  • What is link.phtml? should i add css here?
    – zus
    Dec 16, 2020 at 8:03
  • Yes you can add styling/css here. Dec 16, 2020 at 9:13
  • Where should i place link.html?
    – zus
    Dec 16, 2020 at 9:25
  • view/frontend/templates/ Dec 16, 2020 at 9:26
  • okay. let me do it.
    – zus
    Dec 16, 2020 at 9:28

Your Answer

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

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