0

this is my config file in etc\module :

<?xml version="1.0"?>
<config>
 <modules>
<Net_Toplinks>
  <active>true</active>
  <codePool>local</codePool>
  <version>0.0.1</version>
</Net_Toplinks>
 </modules>
</config>

then added this code in app\code\local\net\Toplinks\etc\congif.xml

<?xml version="1.0"?>
<config>
<modules>
    <Net_Toplinks>
        <version>0.0.1</version>
    </Net_Toplinks>
</modules>
<global>
    <blocks>
        <net_toplinks>
            <class>Net_Toplinks_Block</class>
        </net_toplinks>
    </blocks>
</global>
<frontend>
    <layout>
        <updates>
            <net_toplinks>
                <file>net_toplinks.xml</file>
            </net_toplinks>
        </updates>
    </layout>
</frontend>
 </config>

Added block file as block\Stores.php

<?php 
class Net_Toplinks_Block_Stores  extends Mage_Core_Block_Template {
public function addCustomLinks() 
 {  
    $parentBlock = $this->getParentBlock(); 
    if ($parentBlock ) 
    {
        $text = 'casa';
        //Top link Display Text
        $url = ‘testmodule’;
        $position = 3;
        $parentBlock->addLink($text, $url , $text, $prepare=true, $urlParams=array(), $position , null, 'class="top-link-testmodule"');
    }
    return $this;
}
} 
?>

& finally added this in mycustom-theme folder under \app\design\frontend\net\custom-theme\layout\net_toplinks.xml

<?xml version="1.0"?>
<layout>
<default>
    <reference name="top.links">
        <block type="net_toplinks/stores" name="stores_links">
            <action method="addCustomLinks"></action>
        </block>
    </reference>
</default>
</layout>

Still no link is shown in top links. Currently it shows link in Myaccount dropdown.I want link outside dropdown next to or before Account.

enter image description here

  • No.As you can see I have followed different approach. – user7193478 Nov 30 '16 at 6:41
  • Try this way, <action method="addLink" translate="label title" module="yourmodule"><label>Your Label</label><url helper="url"/><title>title</title><prepare/><urlParams/><position>100</position></action> – Magento 2 Nov 30 '16 at 7:29
  • I tried this but not working...it shows new link under account menu only...I want new link next to Accountmenu – user7193478 Nov 30 '16 at 8:26
  • If you are using reference name ="top.links" then it will come under account menu only – Magento 2 Nov 30 '16 at 8:36
  • then how can I add link next to My Account option? – user7193478 Nov 30 '16 at 8:40
0

In header.phtml, replace the below code under <div class="account-cart-wrapper">

<div class="account-cart-wrapper">
                <a href="<?php echo $this->helper('customer')->getAccountUrl(); ?>" data-target-element="#header-account" class="skip-link skip-account">
                    <span class="icon"></span>
                    <span class="label"><?php echo $this->__('Account'); ?></span>
                </a>

                <!-- Custom links-->
                <a href="<?php echo $this->helper('customer')->getAccountUrl(); ?>">
                    <span class="icon"></span>
                    <span class="label"><?php echo $this->__('Custom Url'); ?></span>
                </a>

                <!-- Cart -->

                <div class="header-minicart">
                    <?php echo $this->getChildHtml('minicart_head'); ?>
                </div>
            </div>

I just the duplicate the account url choose what ever you want and change the design as well

  • IS is correct way? means there is no need to create any module or block? – user7193478 Nov 30 '16 at 9:50
  • No need to create any module for this? – saravanavelu Nov 30 '16 at 10:06
  • but this is not the proper way to give static link like this in magento. – user7193478 Nov 30 '16 at 10:09

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.