1

How can I merge 2 tabs into 1 tab on this admin page:

Customers -> Manage Customers -> Click on a customer

The tabs I'm wanting to merge are "Customer View" and "Account Information".

It seems that the "Customer View" tab loads it's block and template through the customer.xml layout file.

And the "Account Information" tab seems to loads it's block in Tabs.php by calling createBlock(..)->initForm()->toHtml().

I'm unsure how I can use both tab's html content on 1 tab.

2

You can add a function in Customer View tab that returns the html of Account Information tab, i.e. in app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php add:

public function getAccountHtml()
{
    return $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml();
}

then call this function in app/design/adminhtml/default/default/template/customer/tab/view.phtml at the bottom of the file:

<?php echo $this->getAccountHtml(); ?>

and finally hide Account Information tab if it's not a new customer - in app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php replace this:

$this->addTab('account', array(
    'label'     => Mage::helper('customer')->__('Account Information'),
    'content'   => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(),
    'active'    => Mage::registry('current_customer')->getId() ? false : true
));

with this:

if (!Mage::registry('current_customer')->getId()) {
    $this->addTab('account', array(
        'label'     => Mage::helper('customer')->__('Account Information'),
        'content'   => $this->getLayout()->createBlock('adminhtml/customer_edit_tab_account')->initForm()->toHtml(),
        'active'    => Mage::registry('current_customer')->getId() ? false : true
    ));
}
|improve this answer|||||

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.