5

Ok, so i'm trying to show a certain link in the customer account area only if a customer is a particular group.

I can get the link to show by:

<customer_account>
    <reference name="customer_account_navigation" >    
        <action method="addLink" translate="label" module="mymodule"><name>module link</name><path>mymodule/account</path><label>Module Link</label></action>
    </reference>
</customer_account>

But how could I apply a conditional statement to this to only get this to show based on a customer group?

My thoughts are:

public function accountAction()
{
    $this->loadLayout();
    if (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId() == 3){
        // edit layout?
    }
    $this->renderLayout();
}

Is this the correct approach?

1 Answer 1

3

replace // edit layout? with

$navBlock = $this->getLayout()->getBlock('customer_account_navigation');
if ($navBlock) {
    $navBlock->addLink(
         Mage::helper('mymodule')->__('Module Link'),
         Mage::getUrl('mymodule/account'),
         Mage::helper('mymodule')->__('Module Link')
    );
}

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.