3

I'm trying to get url's from Customer Menu (My Account) from Dashboard, in a controller that extends Mage_Customer_AccountController.

enter image description here

I've tried this:

class Namespace_Module_AccountController extends Mage_Customer_AccountController
{

    public function logoutAction()
    {
        $cpBlock = Mage::app()->getLayout()->createBlock('Mage_Customer_Block_Account_Navigation');
        print_r($cpBlock->getLinks());
    }
}

but it displays just an empty array. Any ideas to get Url's?

1 Answer 1

3

The links are added with layout XML (Example), not from the block class itself. So creating a new instance of the block creates the block without any links.

What you can do is load the layout handle for the customer account and then get the navigation block from the layout. Since you override the logoutAction() you probably don't want to render the layout, but you can load the layout without rendering it:

$this->loadLayout('customer_account');
$cpBlock = Mage::app()->getLayout()->getBlock('customer_account_navigation');
1
  • Thx.It works :D . Commented Jun 30, 2016 at 7:44

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.