1

I got this code, and that works well:

<customer_account translate="label">
    <reference name="customer_account_navigation">
        <action method="addLink"><name>someName</name><path>somePath</path><label>Some Label</label></action>
    </reference>
</customer_account>

But I just want to add this customer account navigation link for specific customers. I would be able to write some PHP what acquires the information if the user should view the custom navigation link, but i cannot do this with XML.

What is the solution for this problem?

1

Copy app\design\frontend\PACKAGE\THEME\template\customer\account\navigation.phtml to your theme. Then do changes according to this :

<div class="block block-account">

    ... 

    <div class="block-content">
        <ul>

            <?php
            if(true)//YOUR LOGIC FOR specific customers
            {
                //change values according to your requirements
                $this->addLink("Some Name", "MODULE/CONTROLLER/ACTION", "Some Label", array("PARAMETER"=>"VALUE"));
            }
            ?>

            <?php $_links = $this->getLinks(); ?>
            <?php $_index = 1; ?>

            ...

        </ul>
    </div>
</div>

Yes, remove your XML code

  • That's great! But what is, if I want to write an extension and I don't want to overwrite any files, including files in base directory? – SimonSolutions May 20 '16 at 9:44
  • In this solution, I've not overwritten any core files, we are just using template. I have just called addLink method of Mage_Customer_Block_Account_Navigation block manually which Magento does internally while rendering layout. – Anil Suthar May 20 '16 at 9:52
  • I'm not sure if I understand the solution. I think Magento is just abled to load navigation.phtml one time. If we have two extensions what manipulate the account navigation, installed on the same system, will both be loaded by magento? If yes, does magento create two navigations? – SimonSolutions May 20 '16 at 9:59
  • Sure Magento is just able to load navigation.phtml one time, so put $this->addLink("Some Name",... line in navigation.phtml which is loaded by extension (I mean which is loaded by Magento). Main thing here is to add link, and this line will add one while called by Mage_Customer_Block_Account_Navigation block instance. – Anil Suthar May 20 '16 at 10:09
  • Thank you so far. I want the extension for every theme, so I should put the file to app/design/frontend/base/default/... but here the file already exists. What is the way to go? – SimonSolutions May 20 '16 at 10:15

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.