Friday, 1 April 2016

Select All checkboxes using jQuery

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
var noc = jQuery.noConflict();
noc(document).ready(function () {
    noc("#ckbCheckAll").click(function () {
        noc(".checkBoxClass").prop('checked', noc(this).prop('checked'));
    });
     });
</script>

<input type="checkbox" id="ckbCheckAll" />
    <p id="checkBoxes">
        <input type="checkbox" class="checkBoxClass" id="Checkbox1" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox2" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox3" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox4" />
        <br />
        <input type="checkbox" class="checkBoxClass" id="Checkbox5" />
        <br />
    </p>

simple paging in php

<?php
$vendor_count_data="SELECT COUNT(id) FROM tableName";
$vendor_data="SELECT * FROM tableName";

$pnn = "?pn=";
$sql = $vendor_count_data;
$query = mysql_query($sql);
$row = mysql_fetch_row($query);
$rows = $row[0]; // This is the number of results we want displayed per page
$page_rows = 2; // This tells us the page number of our last page
$last = ceil($rows/$page_rows); // This makes sure $last cannot be less than 1
if($last < 1){ $last = 1; } // Establish the $pagenum variable
$pagenum = 1; // Get pagenum from URL vars if it is present, else it is = 1
if(isset($_GET['pn'])){ $pagenum = preg_replace('#[^0-9]#', '', $_GET['pn']); }
// This makes sure the page number isn't below 1, or more than our $last page
if ($pagenum < 1) { $pagenum = 1; } else if ($pagenum > $last) { $pagenum = $last; }
// This sets the range of rows to query for the chosen $pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows .',' .$page_rows;
// This is your query again, it is for grabbing just one page worth of rows by applying $limit
//$sql = "SELECT * FROM location_city WHERE status ='1' ORDER BY id DESC $limit";
$sql =$vendor_data." ".$limit;
$query = mysql_query($sql);
// This shows the user what page they are on, and the total number of pages
$textline1 = "$rows";
/* Showing 1 to 10 of 11 entries CUSTOM CODE */
//$textline2 = ($pagenum*10)." to ". $last;

if($pagenum==1)
{
$row_start=$pagenum;
}
else
{
$row_start=($page_rows*($pagenum-1))+1;
}
if(($pagenum*$page_rows)<$rows) {
$textline2 = $row_start." to ". ($pagenum*$page_rows);
}else
{
$textline2 = $row_start." to ". $rows;
}

$paginationCtrls = '';
if($last != 1){
$previous = $pagenum - 1;
if($pagenum!=1)
 {
 $paginationCtrls .= "<li><a href='".$pnn."1'>First</a></li><li><a href='".$pnn.$previous."'>Previous</a></li>";
 }
 
for($i = $pagenum-4; $i < $pagenum; $i++){ if($i > 0){ $paginationCtrls .= "<li><a href='".$pnn.$i."'>".$i."</a></li>"; /*}*/ } }
$paginationCtrls .= '<li><a href="javascript:void(0)" class="active">'.$pagenum.'</a></li>';
for($i = $pagenum+1; $i <= $last; $i++){ $paginationCtrls .= "<li><a href='".$pnn.$i."'>".$i."</a></li>";
if($i >= $pagenum+4){ break; } }
$next = $pagenum + 1;
if($last!=$pagenum)
{
$paginationCtrls .= "<li><a href='".$pnn.$next."'>Next</a></li> <li><a href='".$pnn.$last."'>Last</a></li>";
}

 } $list = '';

$i=$row_start;

while($row = mysql_fetch_array($query, MYSQL_ASSOC))
{ ?>
<p><?php echo $i; ?></p>
<p><?php echo $row['id']; ?> </p>

<?php $i++; } ?>
<?php //----show paging here------- ?>
<div class="pages-list">
<ul>
<?php echo $paginationCtrls; ?> 
</ul>
</div>
</div>

Friday, 18 March 2016

how to play youtube video in popup window using jquery

<script type="text/javascript" src="http://www.youtube.com/player_api"></script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<span onclick="playvideo('1');player1.playVideo();" class="yt-link"><h1>Play</h1></span>
<div style="display: none;" id="pop_1" class="video-popup">
 <span onclick="closevideo('1');player1.pauseVideo();" class="closed">X</span>
 <iframe width="800" height="600" frameborder="0" allowfullscreen="true" onload="player1=new YT.Player(this)" src="http://www.youtube.com/embed/8HQIKJBUsQk?rel=0&amp;enablejsapi=1" id="if_"></iframe>
 </div>


<span onclick="playvideo('2');player2.playVideo();" class="yt-link"><h1>Play</h1></span>
<div style="display:none;" id="pop_2" class="video-popup">
 <span onclick="closevideo('2');player2.pauseVideo();" class="closed">X</span>
 <iframe width="800" height="600" frameborder="0" allowfullscreen="true" onload="player2=new YT.Player(this)" src="http://www.youtube.com/embed/X71R64AdoOo?rel=0&amp;enablejsapi=1" id="if_"></iframe>
 </div>

 <span onclick="playvideo('3');player3.playVideo();" class="yt-link"><h1>Play</h1></span>
  <div style="display:none;" id="pop_3" class="video-popup">
 <span onclick="closevideo('3');player3.pauseVideo();" class="closed">X</span>
 <iframe width="800" height="600" frameborder="0" allowfullscreen="true" onload="player3=new YT.Player(this)" src="http://www.youtube.com/embed/BOCvHWoqssI?rel=0&amp;enablejsapi=1" id="if_"></iframe>
 </div>

 <span onclick="playvideo('4');player4.playVideo();" class="yt-link"><h1>Play</h1></span>
 <div style="display:none;" id="pop_4" class="video-popup">
 <span onclick="closevideo('4');player4.pauseVideo();" class="closed">X</span>
 <iframe width="800" height="600" frameborder="0" allowfullscreen="true" onload="player4=new YT.Player(this)" src="http://www.youtube.com/embed/qBLN-sOL6eU?rel=0&amp;enablejsapi=1" id="if_"></iframe>
 </div>                     
 <script>
var noc = jQuery.noConflict();
function playvideo(ytid) {
noc("#pop_"+ytid).show();
}
function closevideo(ids) {
noc("#pop_"+ids).hide();
}
</script>

  

Thursday, 11 February 2016

Magento Add custom image attribute to category


 Just copy paste the below code in header.phtml and run your magento once, your attribute will be created and you can see in backend under manage category. After you are done remove this code again.
 
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->addAttribute('catalog_category', 'sliderimage2', array(
    'group'         => 'General',
    'input'         => 'image',
    'type'          => 'varchar',
    'label'         => 'Slider Image 2',
    'backend'       => 'catalog/category_attribute_backend_image',
    'visible'       => 1,
    'required'        => 0,
    'user_defined' => 1,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
)); ?>

Tuesday, 2 February 2016

How to change the Magento Email Templates

You’ll probably know by now that the transactional email templates in Magento are a bit, with respect, “naff”. To edit through the admin will take forever and a day so here’s a couple of useful solutions to help make things easier.


Locate the email templates.
The Magento email templates are located in (note: “en_US” may change depending on language).
magento\app\locale\en_US\template\email\account_new.html”:
magento\app\locale\en_US\template\email\admin_password_new.html”:
magento\app\locale\en_US\template\email\sales\newsletter_subscr_confirm.html”:
magento\app\locale\en_US\template\email\sales\order_creditmemo.html”:
magento\app\locale\en_US\template\email\sales\order_creditmemo.html”:
magento\app\locale\en_US\template\email\sales\order_invoice.html”:
magento\app\locale\en_US\template\email\sales\order_invoice.html”:
magento\app\locale\en_US\template\email\sales\order_new.html”:
magento\app\locale\en_US\template\email\sales\order_new.html”:
magento\app\locale\en_US\template\email\sales\order_shipment.html”:
magento\app\locale\en_US\template\email\sales\order_shipment.html”:
magento\app\locale\en_US\template\email\sales\order_update.html”:
magento\app\locale\en_US\template\email\password_new.html”:
magento\app\locale\en_US\template\email\wishlist_share.html”:

Magento add CMS Static Block underneath categories in left sidebar

Paste below xml code in custom design part  for call static block after left navigation.

 <reference name="left">
<block type="cms/block" name="book_left_block" after="catalog.leftnav">
<action method="setBlockId"><block_id>book_left_block</block_id></action>
</block>
</reference>

For remove left navigation from left sidebar.
 <reference name="left">
<block type="cms/block" name="book_left_block" after="catalog.leftnav">
<action method="setBlockId"><block_id>book_left_block</block_id></action>
</block>
<remove name="catalog.leftnav" />
</reference>

Tuesday, 12 January 2016

How to remove public and index.php from URL in laravel

1.) First copy all files of public folder and paste in root directry.

2.) open the index file

set path on line no. 21 require __DIR__.'/bootstrap/autoload.php';
and line no. 35   $app = require_once __DIR__.'/bootstrap/app.php';
 
3.) Open .htaccess file and paste following code.

Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]