Thursday 21 March 2013

Get particular category all product images

<?php

$cat_id = 513;  //category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$collection = $category->getProductCollection()->addAttributeToSort('position');
Mage::getModel('catalog/layer')->prepareProductCollection($collection);
?>
<ul id="mycarousel" class="jcarousel-skin-tango">
<li>
<?php
foreach ($collection as $product) {
?>
   
<img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(150, 118); ?>"  alt="<?php echo $this->htmlEscape($product->getName()) ?>" />
 </li>
</ul>
<?php    
  
}

?>

Display all sub categories via phtml file



<div>
<?php
    $children = Mage::getModel('catalog/category')->getCategories(37);
    foreach ($children as $category):
        $category = Mage::getModel('catalog/category')->load($category->getId());
        echo '<li><a href="' . $category->getUrl() . '">' . $category->getName() . '</a></li>';
            $child = Mage::getModel('catalog/category')->getCategories($category->getId());
            foreach ($child as $cat):
                $cat = Mage::getModel('catalog/category')->load($cat->getId());
                echo '<li><a href="' . $cat->getUrl() . '">' . $cat->getName() . '</a></li>';
            endforeach;
    endforeach;
?>
</div>

onchange select option redirect to another page

Just use a onchnage Event for select box.

<select id="selectbox" name="" onchange="javascript:location.href = this.value;">
    <option value="https://www.yahoo.com/" selected>Option1</option>
    <option value="https://www.google.co.in/">Option2</option>
    <option value="https://www.gmail.com/">Option3</option>

</select>
 
And if selected option to be loaded at the page load then add some javascript code

<script type="text/javascript">
    window.onload = function(){
        location.href=document.getElementById("selectbox").value;
    }       
</script>
 
 
for jQuery: Remove the onchange event from <select> tag

jQuery(function () {
    // remove the below comment in case you need chnage on document ready
    // location.href=jQuery("#selectbox").val(); 
    jQuery("#selectbox").change(function () {
        location.href = jQuery(this).val();
    })
})

Monday 11 March 2013

Install Wordpress with wamp




  1. Download wordpress here http://wordpress.org/download/
  2. Stored that wordpress folder in wamp/www
  3. Then give 0777 (Read and write )permission for whole wordpress folder
  4. Create Database in mysql (eg - DB name: test)
  5. click create configuration button (for create config file)
  6. Then click let's go button instead of next button
  7. Then give Database name(eg : name as test),mysql username,password,host name and if you need prefix (please give prefix values that shows in before table name)- click next button
  8. Then click “Run the install ” button for further process
  9. Then give site name ,username,password,confirm password and email id ,click install button
  10. Then click the login button it will redirect to admin (back end )page ,in that page Back button click it redirect to home page


Install Joomla with wamp



  1. Download Joomla files in http://www.joomla.org/download.html
  2. Stored that joomla folder in wamp/www
  3. Then give 0777 (Read and write )permission for whole joomla folder
  4. Please check all wamp services are in enable mode,if you want to check all service enable (wamp server in Quick launch toolbar shows in green color)
  5. Create Database in mysql (eg - DB name: joomla)
  6. select language because joomla supports multiple language(so choose language)
  7. Then Preinstallation files are displayed-no need for change
  8. Then Licence page – click next
  9. Then Database Configuration
    Select Database type as Mysql
    Host name -> Localhost
    Give username, password for mysql
    Give Database name
    click next button
  10. FTP Configuration
    This step is not necessary for local setup,if you could integrate with other server means it is necessary
  11. Main Configuration
    Give site name,admin mail ID,admin username,admin password,confirm password
    if u want ti install sample data click install sample data button(else it is not necessary)
    click next button
  12. It is the last step if you want to remove the installation folder please click remove installation folder
  13. Then click the right top buttons for going to frontend and backend

Monday 4 March 2013

simple javascript validation for textbox



<html>
<head>

<script type="text/javascript">
<!--
var validNums = '0123456789.()+- ';
var validLetters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -';

function validateKeyPress(e, validSet)
{
    var key;
    var keychar;
       
    if(window.event || !e.which) // IE
        key = e.keyCode; // IE
    else if(e)
        key = e.which;   // Netscape
    else
        return true;     // no validation

    keychar = String.fromCharCode(key);
    validSet += String.fromCharCode(8);

    if (validSet.indexOf(keychar) < 0)
      return false;

    return true;
}
//-->
</script>

</head>
<body>
    <form name="myForm">
        <input type="text" size="50" onKeyPress="return validateKeyPress(event, validLetters)" />
    </form>
</body>
</html>