23.02.2015 Views

www.it-ebooks.info

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Backend Development<br />

There are a couple of interesting things happening w<strong>it</strong>h this block class. For starters,<br />

we are extending a different block class, Mage_Adminhtml_Block_Template, and<br />

implementing a new interface, Mage_Adminhtml_Block_Widget_Tab_Interface. This<br />

is done in order to access all the features and functional<strong>it</strong>ies of the Magento backend.<br />

We are also setting the block template inside the construct function of our class; also<br />

under the getCustomerId, we are making use of the Magento global variables to get<br />

the current customer.<br />

Our next step will be to create the corresponding template file for this block,<br />

otherwise we would get an error on the block in<strong>it</strong>ialization.<br />

1. Create a template file called main.phtml at the location app/code/design/<br />

adminhtml/default/default/template/mdg/giftregistry/customer/.<br />

2. Copy the following code into <strong>it</strong>:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Nothing here<br />

<br />

<br />

<br />

<br />

For now, we are just adding placeholder content to the template so that we can<br />

actually see our tabs in action; now, if we go to the customer section in the backend,<br />

we should see that a new tab is available, and clicking on that tab will display our<br />

placeholder content.<br />

By now, we have modified the backend and added a Customers tab to the customer<br />

section just by changing a configuration and adding some simple blocks and a<br />

template file. But so far, this hasn't been particularly useful, so we need a way of<br />

displaying all the customer gift registries under the Gift registry tab.<br />

[ 140 ]<br />

<strong>www</strong>.<strong>it</strong>-<strong>ebooks</strong>.<strong>info</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!