0

I want to make a custom navigation for my theme, I'm overriding navigation.phtml template from Magento_Customer but I realized the links are made it by layout and they always return the link wrapped inside one li element. I'm calling my custom template but I don't know how to get only the link. This is how I'm creating the link:

<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-link" template="Magento_Customer::account/menulink.phtml">
   <arguments>
     <argument name="label" xsi:type="string" translate="true">Account Dashboard</argument>
     <argument name="path" xsi:type="string">customer/account</argument>
   </arguments>
</block>

How magento return link

<li class="nav item"><a href="http://testshop.io/customer/account/edit/">Account Information</a></li>

How I want to have it

<a href="http://testshop.io/customer/account/edit/"><h4><i class="fa fa-icon"></i><br/><span>Account Information</span></a>

Any idea of how to do it?

Thanks!

0

Basically I realized that you could sent arguments to your template and using the method $block->getHref() from the class Magento\Framework\View\Element\Html\Link\Current you could get the link. With this you just have to add a template to the block in your layout and use all the arguments in your template, like this:

<block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-account-link" template="Magento_Customer::account/menulink.phtml">
   <arguments>
     <argument name="label" xsi:type="string" translate="true">Account Dashboard</argument>
     <argument name="path" xsi:type="string">customer/account</argument>
     <argument name="icon" xsi:type="string">user</argument>
   </arguments>
</block>

and in your layout like this:

<a href="<?php echo $block->getHref() ?>" class="list-group-item active text-center">
    <h4 class="glyphicon glyphicon-<?php echo $block->getIcon() ?>"></h4><br/><?php echo $block->getLabel() ?>
</a>

Hope somebody found this helpful.

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.