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>';
  • Advertisements

    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();
    			if($prodCount=='0')
    			{
    				$prodCounts = '';
    			}
    			else
    			{
    				$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


    "THARIKIDA"

    <html>
    <head>
    <title>Email Validation</title>

    function validate()
    {
    var str;
    var t=1;
    str =document.getElementById(’email’).value;
    if(document.getElementById(’email’).value==””)
    {
    alert(“Empty”);

    }
    var res = str.split(‘@’);
    if(str.split(‘@’).length!=2)
    {
    alert(“zero @ OR morethan one @ “);
    t=0;
    }
    var part1=res[0];
    var part2=res[1];

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

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

    if(t==1)
    alert(“woooooooooooooooooooowwwww…it is a valid email”);

    }


    </head>

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

    View original post

    Simple jQuery Accordion


    Gopal Sikdar

    jQuery

    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; });

    })

    (jQuery);

    HTML

    Panel 1

    Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.

    Panel 2

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

    Panel 3

    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.

    CSS

    .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' );