Thursday 29 January 2015

Tutorial on install, setup and getting started in Symfony 2 PHP MVC framework with Hello World example on Windows


PHP is one of the widely used web development language, and Symfony is an Enterprise level PHP MVC framework. Here the following link is explaining the steps for getting started with Symfony in Windows with a 'Hello World' example in Symfony.

http://www.tinywall.info/2014/05/install-setup-getting-started-tutorial-php-symfony-hello-world-example-windows.html

Friday 9 January 2015

How to Display Comments on Home Page of a WordPress Site

 I have just put $withcomments = "1"; before comments_template() function.
<?php  
$withcomments = "1"; 
comments_template(); 
 ?>

Thursday 8 January 2015

How to Get Different Themes on Different WordPress Pages

Select different themes for one or more wordpress pages, posts or other non-admin pages or site home. Please visit the below link.

https://wordpress.org/plugins/jonradio-multiple-themes/



Monday 5 January 2015

How to import .sql file in mysql database using php


<?php
           // Name of the file
          $filename = 'filename.sql';
          // MySQL host
          $mysql_host = 'localhost';
         // MySQL username
         $mysql_username = 'root';
        // MySQL password
        $mysql_password = '';
        // Database name
        $mysql_database = 'dbName';

        // Connect to MySQL server
        mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to           MySQL server: ' . mysql_error());
       // Select database
       mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());

      // Temporary variable, used to store current query
      $templine = '';
     // Read in entire file
     $lines = file($filename);
     // Loop through each line
      foreach ($lines as $line)
       {
         // Skip it if it's a comment
           if (substr($line, 0, 2) == '--' || $line == '')
           continue;

        // Add this line to the current segment
        $templine .= $line;
       // If it has a semicolon at the end, it's the end of the query
        if (substr(trim($line), -1, 1) == ';')
       {
          // Perform the query
            mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' .                      mysql_error() . '<br /><br />');
           // Reset temp variable to empty
          $templine = '';
          }
}
 echo "Tables imported successfully";
?>

Friday 2 January 2015

How to display Posts in lightbox with pagination In WordPress

// Create post_lightbox.php template or simple page

<?php
         require_once( './wp-load.php' );
         $post_id = $_REQUEST['post_id'];

         $author_query = array('posts_per_page' => '-1');  
         $author_posts = new WP_Query($author_query);
         if($author_posts->have_posts()):
         while($author_posts->have_posts()) : $author_posts->the_post();  
         ?>
        <p><a  class="inline post-<?php echo get_the_ID();?>" href="#post-<?php echo get_the_ID();?>"><?php the_title(); ?></a></p>
        <div id="post-<?php echo get_the_ID();?>" class="inline-post">
            <?php  wdpv_vote(); ?>   
            <h2 class="inline-header" style="text-align:center;">
                <a href="<?php the_permalink();?>" target="_blank"><?php the_title(); ?></a>
            </h2>
            <div class="userpro-post-stat lightbox-icons">
                <a href="<?php the_permalink(); ?>#comments"><i class="userpro-icon-comment"></i> <?php echo (get_comments_number())?get_comments_number().' Comments':'Leave a Comment'; ?></a> |
                <a href="#"><i class="userpro-icon-time"></i><?php echo get_the_date();?></a> |
                <a href="#"><i class="userpro-icon-user"></i> By <?php the_author(); ?></a>
               
            </div>
                       
            <div class="inline-content">
                 <?php the_content(); ?>
             
            </div>
                   
        </div>
    <?php          
    endwhile;
    else:
    echo '<h5 style="margin-top: 24px;text-align: center;">No Matches Found!</h5>';
    endif;?>
  
==================================================================

<!--open posts in light box-->
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>-->
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/colorbox.css" />
    <script src="<?php echo get_template_directory_uri(); ?>/js/jquery.colorbox.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function (){
   

 jQuery('.inline-post').on('click',function(event){        
//event.preventDefault();
var id = jQuery(this).attr('href');
var post_id = id.split("-");
 var post_class= 'post-'+post_id[1];
jQuery.ajax({ 
type: "POST",                 
url:  "<?php echo home_url('/');?>post_display_in_lightbox.php", 
   data: 'post_id='+post_id[1],   
   beforeSend: function() {
        // setting a timeout
        jQuery('.lightbox-loading').css('display','block');
    },
   success: function (msg) { 

  jQuery('#all_ajax_posts').html(msg);
   jQuery('.lightbox-loading').css('display','none');

   var mmmm= setInterval(function() {
     jQuery('.'+post_class).trigger('click');
   
  //jQuery(".inline").colorbox({inline:true,rel:'inline', transition:"none", width:"85%", height:"100%",position:'fixed'});
   
}, 500);

jQuery(".inline").colorbox({inline:true,rel:'inline', transition:"none", width:"85%", height:"100%",position:'fixed'});
setTimeout(function(){clearInterval(mmmm); }, 2000);
},
error: function () {                 
  alert('Error');              

});  
       
});
   
});
   
</script>


Note: Download css and js files from colorbox-master site.