Monday, August 10, 2015

Wordpress- get facebook like count by url

Wordpress-  get facebook like count by url

$link   = get_permalink( $post->ID );
// make the call
$call   = 'https://graph.facebook.com/fql?q=SELECT%20like_count%20FROM%20link_stat%20WHERE%20url=%27' . urlencode( $link ) . '%27';
// do the call
$rmget  = wp_remote_get( $call, array( 'sslverify' => false ) );
// error. bail.
if( is_wp_error( $rmget ) ) {
    return false;
}
// parse return values
$return = json_decode( $rmget['body'] );
// bail with no decoded
if ( empty( $return ) || empty( $return->data ) || empty( $return->data[0] ) || empty( $return->data[0]->like_count ) ) {
    return false;
}

// get the count
echo 'CONT is ', $count  = $return->data[0]->like_count;

Monday, July 13, 2015

Magento - set cron using cpanel

  1. Go to cpanel login
  2. Look for Cron section
  3. If you know the path of the cron file in the filemanager, enter the command like below. You can set cron for minutes, hourly, daily, monthly or for weekdays.
  4.  
  5.  If you don’t know the file path then use this command and configuration. As said you can schedule the cron as you want, I have configured here to run the cron every 5 minutes. 

Sunday, July 12, 2015

Magento - set cron using cpanel

Magento - set cron using cpanel

wget http://www.your-site.com/cron.php >/dev/null 2>&1

In cron.php add after line 47
$isShellDisabled = true;

Wednesday, July 8, 2015

jQuery- All child checkbox checked on checked in jquery


<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
var nocon = jQuery.noConflict();
nocon(document).ready(function(){

  nocon(".chk").click(function(ev) {

    nocon(this).siblings('ul').find("input[type='checkbox']").prop('checked', this.checked);
        ev.stopImmediatePropagation();
  });
});
</script>

<ul><li><input type="checkbox" class="chk"><a href="">1</a>
   <ul>
   <li>
   <input type="checkbox"class="chk"><a href="">2_1</a>
                       <ul>
                       <li><input type="checkbox" class="chk"><a href="">3_1</a></li>
                       <li><input type="checkbox" class="chk"><a href="">3_2</a></li>
                       </ul>
                   
                      </li>
                    <li>
                      <input type="checkbox"class="chk"><a href="">2_2</a>
                       <ul>
                       <li><input type="checkbox" class="chk"><a href="">3_3</a></li>
                       <li><input type="checkbox" class="chk"><a href="">3_4</a></li>
                       </ul>
                   
                      </li>
                      </ul>
                      </li>
        <li><input type="checkbox" class="chk"><a href="">1</a>
   <ul>
   <li>
   <input type="checkbox"class="chk"><a href="">2_1</a>
                       <ul>
                       <li><input type="checkbox" class="chk"><a href="">3_1</a></li>
                       <li><input type="checkbox" class="chk"><a href="">3_2</a></li>
                       </ul>
                   
                      </li>
                    <li>
                      <input type="checkbox"class="chk"><a href="">2_2</a>
                       <ul>
                       <li><input type="checkbox" class="chk"><a href="">3_3</a></li>
                       <li><input type="checkbox" class="chk"><a href="">3_4</a></li>
                       </ul>
                   
                      </li>
                      </ul>
                      </li>           
                   
                      </ul>

Wednesday, July 1, 2015

Magento- Images re-size in Magento


Best article Click here

Magento- Resize Product image without white space in magento

Magento-  Resize Product image without white space in magento

<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize(210,210); ?>

Thursday, June 4, 2015

javascript- dynamically adding file upload fields to a form using javascript

<script language="javascript" type="text/javascript">
       var a=1;
        function AddMoreImages() {

         
            var fileUploadarea = document.getElementById("fileUploadarea");
          
            //var newLine = document.createElement("br");
            //fileUploadarea.appendChild(newLine);
            var newFile = document.createElement("input");
            newFile.type = "file";
          

      
             
            newFile.setAttribute("id", "FileUpload" + a);
            newFile.setAttribute("name", "file[]");
            newFile.setAttribute("class", "browse-snap");
            var div = document.createElement("div");
            div.appendChild(newFile);
            div.setAttribute("id", "div" + a );
            fileUploadarea.appendChild(div);
          
             var newbot= document.createElement("input");
                newbot.type="Button";
                newbot.setAttribute("id","b" + a);
                newbot.setAttribute("value","remove" + a);
                newbot.setAttribute("class","close-btn");
                newbot.setAttribute("onclick","deletefile(this.id);");
                var divid=document.getElementById("div" + a);
               fileUploadarea.appendChild(div).appendChild(newbot);
             
            a++;
            return false;
        }
      
        function deletefile(abf)
        {
        a--;
        var abf1 = abf.split("b");
        //var uplod=document.getElementById("fileUploadarea");
        var im=document.getElementById("div" + abf1[1]);
        im.parentNode.removeChild(im);
        return false;
      
        }
    </script>
<body>
    <form id="form1">
    <div>
        <div id="fileUploadarea">
          
        </div>
        &nbsp;
        <input style="display: block;" id="btnAddMoreImages" type="button" value="Add more images" onClick="AddMoreImages();" />
      
    </div>
    </form>
</body>
</html>

PHP- download file in php

PHP- download file in php

function Download($path, $speed = null)
{
if (is_file($path) === true)
    {
set_time_limit(0);
while (ob_get_level() > 0)
        {
            ob_end_clean();
        }
$size = sprintf('%u', filesize($path));
        $speed = (is_null($speed) === true) ? $size : intval($speed) * 1024;
        header('Expires: 0');
        header('Pragma: public');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Type: application/octet-stream');
        header('Content-Length: ' . $size);
        header('Content-Disposition: attachment; filename="' . basename($path) . '"');
        header('Content-Transfer-Encoding: binary');

        for ($i = 0; $i <= $size; $i = $i + $speed)
        {
            echo file_get_contents($path, false, null, $i, $speed);

            while (ob_get_level() > 0)
            {
                ob_end_clean();
            }

            flush();
            sleep(1);
        }

        exit();
    }

    return false;
}
echo Download($file_path='$file_path='C:\wamp\www\s.pdf'',500);

Magento - how to get product all image in magento

Magento - how to get product all image in magento

<?php
$product = Mage::getModel('catalog/product')->load($_product->getId());
             foreach ($product->getMediaGalleryImages() as $image) {
                        echo var_export($image->getUrl());
                       
   } ?>

Magento-how to get category thumbnail image in magento

Magento-how to get category thumbnail image in magento

<?php  $catId = $_category->getId(); ?>
<?php $thumb = Mage::getModel('catalog/category')->load($catId)->getThumbnail();?>
<img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$thumb;?>" >

Magento- get current url in magento

Magento- get current url in magento 
$currentUrls = Mage::helper('core/url')->getCurrentUrl();

Friday, May 29, 2015

Magento - Change options of configurable product to radio button

Replace the configurable.phtml code with below code:
<?php
$_product    = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
    <dl>
    <?php foreach($_attributes as $_attribute): ?>
        <dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
        <dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
            <div class="input-box">
                <select style="display:none;" name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
                   
                  </select>
              </div>
        </dd>
    <?php endforeach; ?>
    </dl>
    <script type="text/javascript">
        var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
    </script>
<?php endif;?>
<div id="r"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#attribute<?php echo $_attribute->getAttributeId() ?> option").each(function(i, e) {
    if(jQuery(this).val() == '')
    {}
    else
    {
    jQuery("<input type='radio' name='r' />")
        .attr("value", jQuery(this).val())
        .attr("checked", i == 0)
        .click(function () {
            jQuery("#attribute<?php echo $_attribute->getAttributeId() ?>").val(jQuery(this).val());
        })
        .appendTo("#r");
        jQuery("<span >&nbsp;&nbsp;&nbsp;"+jQuery(this).html()+"&nbsp;&nbsp;&nbsp;</span>")
        .appendTo("#r");
    }
       
});
});


</script>

Monday, May 18, 2015

Wordpress- Some very useful plugins

Wordpress- Some very useful plugins 

1. Plugin for managing custom post types, custom taxonomies and custom fields.
 Types :  https://wordpress.org/plugins/types/

2.Append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types.
Attachments : https://wordpress.org/plugins/attachments/

3. Add Multiple Featured Images To WordPress Posts
Dynamic Featured Image : https://wordpress.org/plugins/dynamic-featured-image/screenshots/ 

4. WordPress user management plugin. Custom user profile, custom Login, registration with extra fields and many more.
User Meta : https://wordpress.org/plugins/user-meta/

5.  Responsive Menu : https://wordpress.org/plugins/responsive-menu/
6. Contact Form 7  : https://wordpress.org/plugins/contact-form-7/

7.  Better Notifications for WordPress : Send customisable HTML emails to your users for different WordPress notifications.
https://wordpress.org/plugins/bnfw/

8. : Front End PM:  Front End PM is a Private Messaging system and a secure contact form to your WordPress site.This is full functioning messaging system from front end.

9. Custom Favicon:  https://wordpress.org/plugins/custom-favicon/

10. https://wordpress.org/plugins/custom-taxonomy-category-and-term-fields/screenshots/





Wednesday, May 13, 2015

Wordpress- get custom usermeta with Types plugin

 Wordpress- get custom  usermeta with Types plugin


echo do_shortcode('[types usermeta="user-badges-label"  proportional="true" user_id="'.$userid.'"]');

jQuery- to get Index using class

jQuery- to get Index using  class
 
 
jQuery(document).ready(function() { 
 jQuery( ".class-name" ).each(function( index ) {
 alert(index);
 
 });
});