0

My memories in M1x, From xml use aParams tag can add class name for anchor. But in M2 seem this tag have removed. Where can i find this params in code Anyone have experience on this case


@Marius top links from M1 i can use xml to add class name to anchor

xml you can see below link
http://pastebin.com/raw.php?i=wWLmXEnW
I want to do that in M2 but seem this way not work. Any idea on this case
What class name will render top links in M2?

Many thanks

  • can you provide an example of what you did in M1 and what do you expect on M2? your question is not really clear. – Marius Sep 23 '15 at 8:41
  • @marius take a notice – mrtuvn Sep 24 '15 at 2:24
1

If you need add class to top.links block use layouts like

<referenceBlock name="top.links">
  <arguments>
       <argument name="css_class" xsi:type="string">my-class</argument>
  </arguments>
</referenceBlock>

if you need add new link to top.links use layout like

    <referenceBlock name="top.links">
        <block class="\Magento\Framework\View\Element\Html\Link" name="top-link-myaccount">
            <arguments>
                <argument name="label" xsi:type="string">My Account</argument>
                <argument name="href" xsi:type="url">customer/getAccountUrl</argument>
                <argument name="class" xsi:type="string">top-link-myaccount</argument>
            </arguments>
        </block>
    </referenceBlock>
  • i have tried this way but getting DOM error – mrtuvn Oct 2 '15 at 10:27
  • can you show the layout file – KAndy Oct 2 '15 at 11:31
  • dropbox.com/s/btsxnab71kfwnaf/… – mrtuvn Oct 2 '15 at 16:31
  • 1
    This way, the A element will get a Class. How can I modify this XML in order to give its li parent element a class? – Max Oct 6 '16 at 8:14
  • For some reason <argument name="css_class" xsi:type="string">my-class</argument> does not take effect for anchor elements on M2.1.x – Iveta Allogenes Jan 23 '18 at 18:22

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.