How to add a New Reference or Position in Magento

There is often a need to create a new position in Magento apart from the default one. In Magento we call it References. Now the question is How To Create One ?.


It’s pretty simple to add new Reference in Magento. Below are the steps on how to do it.

First thing we need to do is Create a New Structural Block.

Step 1 : Name the Structural Block

Open the file layout/page.xml in your active theme folder. Inside you will find lines like:

<block type=”core/text_list” name=”left” as=”left”/>
<block type=”core/text_list” name=”content” as=”content”/>
<block type=”core/text_list” name=”right” as=”right”/>

Let’s mimic this and add a new line somewhere inside the same block tag.

<block type=”core/text_list” name=”newreference” as=”newreference”/>

Now we told Magento that new structural block exists with the name “newreference”. Magento still doesn’t know what to do with it.

Step 2: Tell Magento where to place it

We now need to point Magento where it should output this new structural block. Goto template/page folder in our active theme folder. You will notice different layouts there. Let’s assume we want the new structural block to appear only on pages that use 2-column layout with right sidebar. In that case we should open 2columns-right.phtml file.

Now, we wish to show the newreference above the footer as shown in the figure. To do so we will need to open the file 2columns-right.phtml and insert the code

<div><?php echo $this->getChildHtml(‘newreference’) ?></div>

into the file. The code will look something like this.

<div class=”main-container col2-right-layout”>
<div class=”main”>
<?php echo $this->getChildHtml(‘breadcrumbs’) ?>
<div class=”col-main”>
<?php echo $this->getChildHtml(‘global_messages’) ?>
<?php echo $this->getChildHtml(‘content’) ?>
<div class=”col-right sidebar”><?php echo $this->getChildHtml(‘right’) ?></div>
<div><?php echo $this->getChildHtml(‘newreference’) ?></div>

Step 3: Entering data for that structural block

We have the block properly placed, but unfortunately nothing is new on the frontsite. Let’s populate the new block with something. So let’s create new file app/design/frontend/[base]/[default]/template/newreference.phtml with the following content:

<h1 style=”background-color:yellow”>Hello New Reference!</h1>

You can put any content or images in this file apart from text.

Go to appropriate layout XML file (page.xml) and add this block to appropriate place (for testing purpose you could place it under “default” handle).

<reference name=”newreference”>
<block type=”core/template” name=”newReferenceBlock” template=”newReference.phtml” />

Now if you visit your frontend you will see the new reference text.

PLease leave your comment in case of any doubts. Please provide your feedback on it.


5 thoughts on “How to add a New Reference or Position in Magento

  1. hi ali,
    i updated my site magento 1.8.1.
    when i m on success page , there is error to print pdf all detail

    Fatal error: Call to a member function getRealOrderId() on a non-object in /home/kidsenco/beta/app/code/core/Mage/Sales/Block/Order/Print.php on line 39


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s