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.
Continue reading

How to share custom data on social network site !!!

For Facebook share

<a id="ref_fb" href=";p[title]=<?php echo $ftitle;?>&amp;p[summary]=<?php echo $fdescription;?>&amp;p[url]=<?php echo urlencode($fshare_url);?>&amp;
p[images][0]=<?php echo $fimage_url;?>" onclick=", '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600'); return false;">&nbsp;</a>

For Twitter share

<a id="ref_tw" href="<?php echo $ttitle; ?>+<?php echo urlencode($tshare_url);?>" onclick=", '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;">&nbsp;</a>

For Linkedin share

<a id="ref_lkd" href="<?php echo urlencode($lshare_url);?>&title=<?php echo strip_tags($ltitle); ?>&source=<?php echo urlencode($siteurl);?>"onclick=", '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false;">&nbsp;</a>

For Google+ share

<a id="ref_gp" href="<?php echo urlencode($gshare_url);?>"
onclick=", '', 'menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600');return false">&nbsp;</a>
Please define  values  of varibles for better result !!!  

How to validate email id using checkdnsrr() function in PHP

Are you tired of dummy email id’s being used on your website. Like, etc ?

You can use PHP function


It checks whether the dns value is valid or not. Only the email id with valid domain name will be accepted 😉

This is inspired from the original post of one of our Author SNEHAL. Originally posted on his blog.

checkdnsrr() function will take an email address and performs a DNS lookup on the specified host (either a hostname or IP address). You can use this function before sending emails. The function will return an error informing the user that the domain related to email address probably doesn’t exist.

This function can look up the following record types:

bool checkdnsrr (string $host [, string $type = “MX” ] )

Continue reading

How to submit a form using AJAX

This is a Registration.php file

In This file Simple create registration form and submit by using AJAX

<!DOCTYPE html>
<script src=""></script>
<script src="">
$('#myForm').on('submit',function(event) {
url:'success.php',          //target file
data:$(this).serialize(),    //translate data structure and object

$("#success").show();       // Show Success Message==

$("#error").show().fadeOut(5000);   //===Show Error Message====
event.preventDefault();         //To Avoid Page Refresh and Fire the Event "Click"

<h2 >Registration Form</h2>

<table align:center>
<form id="myForm" method="POST" action="" >
<tr><td>Name :</td><td><input type="text" name="name" required></td></tr>
<tr><td>SarName :</td><td><input type="text" name="sarname" required></td></tr>
<tr><td>Birthday :</td><td><input type="date" name="bday" required></td></tr>
<tr><td>E-mail :</td><td><input type="email" name="email" required></td></tr>
<tr><td>Password :</td><td><input type="password" name="password" required></td></tr>
<tr><td>re-Password :</td><td><input type="password" name="passward" required></td></tr>
<tr><td><button type="submit" name="submit" id="submit">submit</button></td> </tr>
<span id="error" style="display:none; color:#F00">Some Error!Please Fill form Properly </span>

<span id="success" style="display:none; color:#0C0">All the records are submitted!</span>

<?php ?>


Continue reading

How to display blog posts (Fishpig module) with featured images on magento homepage?

When we integrate fishpig with magento we can have one folder
“wordpress” in the template folder.(path:- app\design\frontend\base\default\wordpress).
in that we can create our custom folder like “xyz”.
in that we need to create one .phtml file called “xyz.phtml”.

the followings code returns the post name, post featured image etc…

 $posts = $this->getPosts() ;
if (count($posts) > 0): 
 foreach($posts as $post): ?>
<img src=" <?php echo $image_url = $post->getFeaturedImage()->getAvailableImage();?>" />
// also call here getAvailableImage(); for  Featured image  plz take <img> tag
echo  getPermalink(); // Post link
echo $post_date = $post->getPostDate(); // Post date
 echo $post_day = date('l', strtotime($post_date)); // Day of Post
echo $post_title = $post->getPostTitle(); // Post Title

Then call this template in home page slide section like,

<?php createBlock('wordpress/sidebar_widget_posts')->
echo $blog->toHtml();

Custom THANK YOU page in Magento – success.phtml PART-2

In this post we will try to cover up how to get the cart details on Success Page. This is a second part of our post THANK YOU PAGE. If you are directly reading this post we recommend to refer the previous post before going through this.
The link of the previous post is


Now lets start how we will get the Cart Summary in Success Page.

1) Goto : app/design/frontend/YOURTHEME/default/template/checkout/success.phtml
I hope you are already on this page as you have already read the first part of this post 😉
2) Here, I am shamelessly pasting the whole code for obtaining Cart detail from my success.phtml. I’ll explain each bit below the code. Continue reading

How to display discount percentage for Special Price in Magento

This post is posted on Saurabh Patel’s Request. He required this thing to be done in Magento.

To display Special Price percentage discount in Magento, you need to do following steps

1) Goto app/design/frontend/YOURTHEME/default/template/catalog/product/price.phtml
2) Basically we need to find the percentage of the difference between the actual price and special price. So first we will obtain both special and actual price of the product using following code

$_actualPrice = $_store->roundPrice($_store->convertPrice($_product->getPrice()));
$_convertedFinalPrice = $_store->roundPrice($_store->convertPrice($_product->getFinalPrice()));

Here Both these prices are already retrived in the file price.phtml

3) To get the discount percentage use the following code

$_discountPercentage = round((($_actualPrice-$_convertedFinalPrice)/$_actualPrice)*100);

Now you got the discount percentage stored in $_discountPercentage variable. Next you need to display this percentage only where Special price is available. To do so you need to find the class “special-price” and under that class you can enter the discount amount percentage.

You can simply call it using echo $_discountPercentage.”%”. You can format it as per your requirement.

Thats it. Please provide your feedback as a comments