Display Category Images in Navigation

To display the images of categories in the main navigation menu, we need to update two files.

Firstly in Model file. (/app/code/core/Mage/Catalog/Model/Observer.php)

Update following code in Function Name: _addCategoriesToMenu

$categoryData = array( 
        'name' => $category->getName(),
        'id' => $nodeId,
        'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
        'is_active' => $this->_isActiveMenuCategory($category),
        'thumbnail' => Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()

Then go into Html folder. (app/code/core/Mage/Page/Block/Html/Topmenu.php)

Update the following line of code at line 128 in

Function name: _getHtml

$urls = Mage::getBaseUrl('media').'catalog/category/'.$child->getData('thumbnail');
$img = '<img src="'.$urls.'" />';

$html .= '
  • _getRenderedMenuItemAttributes($child) . '>'; $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '>' . $this->escapeHtml($child->getName()) . ' '.$img.' </a>';
  • Display product count of a category in main navigation

    To display Product Count of a particular category in the main navigation, just include the following code in function _addCategoriesToMenu() of the observer file. The Observer file is located at app\code\core\Mage\Catalog\Model\Observer.php

    $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
    			$prodCount = $prodCollection->count();
    				$prodCounts = '';
    				$prodCounts = ' ('.$prodCount.')';
    			$categoryData = array(
                    'name' => $category->getName().$prodCounts,
                    'id' => $nodeId,
                    'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
                    'is_active' => $this->_isActiveMenuCategory($category),
    				'thumbnail' => Mage::getModel('catalog/category')->load($category->getId())->getThumbnail()

    Continue reading

    Email validation in javascript without using regular expression


    <title>Email Validation</title>
    <script type=”text/javascript”>
    function validate()
    var str;
    var t=1;
    str =document.getElementById(’email’).value;

    var res = str.split(‘@’);
    alert(“zero @ OR morethan one @ “);
    var part1=res[0];
    var part2=res[1];

    // part1
    alert(“no content bfr @”);
    if(part1.split(” “).length>2)
    alert(“Invalid:Space before @”)

    //chk afr @ content:  part2
    var dotsplt=part2.split(‘.’);  //alert(“After @ :”+part2);
    alert(“dot missing”);
    if(dotsplt[0].length==0 )
    alert(“no content b/w @ and dot”);
    if(dotsplt[1].length<2 ||dotsplt[1].length>4)
    {alert(“err aftr dot”);

    alert(“woooooooooooooooooooowwwww…it is a valid email”);



    <input type=”text” name=”email” id=”email”  />
    <input type=”button” name=”btnok” onclick=”validate()” />

    View original post

    Simple jQuery Accordion

    Gopal Sikdar


    Make sure either to run on DOM ready or at the bottom of the page.

    (function($) {

    var allPanels = $(‘.accordion > p’).hide();

    $(‘.accordion > h1 > a’).click(function() { allPanels.slideUp();

    $(this).parent().next().slideDown(); return false; });




    <div class=”accordion”>

    <h1><a href=””>Panel 1</a></h1>

    <p>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</p>

    <h1><a href=””>Panel 2</a></h1>

    <p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque felis.</p>

    <h1><a href=””>Panel 3</a></h1>

    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.</p>



    .accordion { margin: 50px;

    h1, p { padding: 10px; border: 1px solid black; border-bottom: 0;

    &:last-of-type { border-bottom: 1px solid black; }

    View original post 29 more words

    How to add excerpt on a Page in WordPress without plugin

    To add an excerpt field in WordPress Pages like we have in Posts, just paste the following code to your functions.php and have fun !!

    add_post_type_support( 'page', 'excerpt' );