Showing posts from 2015

Display Twitter Bootstrap Tooltip on Page Load (Initalize)

$('.tooltip-block').tooltip().eq(0).tooltip('show').tooltip('disable').one('mouseout', function() { $(this).tooltip('enable'); });

Magento: All Categories and respective Thumbnails in Magento 1.9

Got it. Here is the result, we need to the attribute to the collection and then get the image from the respective folder:

<?php $_helper = Mage::helper('catalog/category'); ?> <?php $_categories = $_helper->getStoreCategories(false, true, false) //Here is the solution ->addAttributeToSelect('image') ->addOrderField('name'); ?> <?php if (count($_categories) > 0): ?> <ul> <?php foreach($_categories as $_category): ?> <li> <a href="<?php echo $_helper->getCategoryUrl($_category) ?>"> <?php echo $_category->getName(); echo '<img src="'$_category->getImageUrl().'" width="100" height="100"/>'; ?> </a> …

Magento: Display Dumping Variables

The native Zend_Debug::dump() function is a step forward from the usual approach to dumping variables to debug your code (usually by using var_dump or print_r).


Magento: How to remove index.php from URL in IIS

First you need create web.config file under magento root folder then copy below into web.config

<?xml version="1.0" encoding="UTF-8"?> <configuration>  <system.webServer>   <rewrite>    <rules>     <rule name="MYRule" stopProcessing="true">     <match url=".*" ignoreCase="false" />     <conditions>     <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" />     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />     <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />     </conditions>     <action type="Rewrite" url="index.php" />    </rule>    </rules>   </rewrite>  </system.webServer> </configuration>

Magento: Get tax value

$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object $totals['tax']->getValue();

Magento: Get Grandtotal without Tax

$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object $grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value

Magento: Get Subtotal without Tax

$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object $subtotal = $totals["subtotal"]->getValue(); //Subtotal value

Magento: How to remove or add the Welcome Text "Default welcome msg!"

By default Magento comes with the following Welcome Text: Default welcome msg! To remove the Magento Welcome Text, log in to your Magento admin panel and go to System > Configuration > General section > Design. Then click Header and remove the Default welcome msg! text from the Welcome Text field. Click Save Config to save the change. Now you can check your store's frontend - the welcome text will not be shown there.

Magento: How to Hide breadcrumbs via the admin-panel?

Best way to do it, Go to admin page:

System --> Configuration --> Web --> Default Pages --> Show Breadcrumbs for CMS Page

- Choose No for hide breadcrumbs

CSS: Fixed :nth-child in IE8

/* li:nth-child(1) */#nav ul li:first-child a {border-top:5px solid red;}/* li:nth-child(2) */#nav ul li:first-child + li a {border-top:5px solid blue;}/* li:nth-child(3) */#nav ul li:first-child + li + li a {border-top:5px solid green;}​

PHP: Calculate duration between two dates

<?php $date11 = '2013-03-12'; $date22 = '2013-03-15'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // 3 ?>
<?php $date11 = '2013-03-15'; $date22 = '2013-03-12'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // -3 ?>

jQuery: How to close a dropdown on clicking anywhere on the body?

jQuery: How to close a dropdown on clicking anywhere on the body? The dropdown is displayed when user click on the 'more' button, to hide the dropdown again user should click on the 'more' button again. But if user want to close the dropdown by clicking anywhere on the body so we need add code on click document.
HTML ----- <a class="select-link" href=""><a href="#" class="select-link">Select List</a> <ul class="dropdown-menu-list"> <li><a href="#">My item name 1</a></li> <li><a href="#">My item name 2</a></li> <li><a href="#">My item name 3</a></li> <li><a href="#">My item name 4</a></li> </ul> CSS --- .dropdown-menu-list {display:none;} jQuery --- $(".select-link").o…

MySql: Fixed sort datetime string field dd-mm-yyyy

If you using a system where the dates are stored as strings in the format dd/mm/yyyy or dd-mm-yyyy. Is it possible to convert this to yyyy-mm-dd in a sort Query.


year ---- 20-08-2015 02-03-2010 03-03-2011 02-03-2011 02-04-2011
SELECT `year` FROM `Product` WHERE 1 order BY DATE_FORMAT(STR_TO_DATE(`year`, '%d-%m-%Y'), '%Y-%m-%d') DESC

PHP: Date Difference for PHP 5.2

function days_diff($d1, $d2) {     $x1 = days($d1);     $x2 = days($d2);      if ($x1 && $x2) {         return abs($x1 - $x2);     } } function days($x) {     if (get_class($x) != 'DateTime') {         return false;     }      $y = $x->format('Y') - 1;     $days = $y * 365;     $z = (int)($y / 4);     $days += $z;     $z = (int)($y / 100);     $days -= $z;     $z = (int)($y / 400);     $days += $z;     $days += $x->format('z');     return $days; } // Call function$start_date = '2015-08-19 15:18:19';$end_date = '2015-08-22 15:18:19';$date1=date_create(date('Y-m-j',strtotime($start_date))); $date2=date_create(date('Y-m-j',strtotime($end_date))); $diff=date_diff($date1,$date2);echo $diff;

List of svg support in email template


Bootstrap 3: Equal Height Columns with jQuery

When you want height of each have the same height using coloumn of Bootstrap my recommend you should Javascript calculate height of each row if you using css maybe not support all browser.

1. Html Code

<div class="row eq-heights">       <div class="eq-col-sm-4 eq-col-md-4 col-md-4">       <div class="content clearfix">column 1 first in source </div>        </div>     <div class="eq-col-sm-4 eq-col-md-4 col-md-4">         <div class="content clearfix">col 2 second in source </div>        </div>     <div class="eq-col-sm-4 eq-col-md-4 col-md-4">         <div class="content clearfix"> Third in source. something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd </div>        </div> </div>

jQuery to hide a DIV when the user clicks outside of container

- Html code

<a href="#" class="select-link">Select List</a> <ul class="dropdown-menu-list">     <li><a href="#">My item name 1</a></li>     <li><a href="#">My item name 2</a></li>     <li><a href="#">My item name 3</a></li>     <li><a href="#">My item name 4</a></li> </ul>
- Css Code

.dropdown-menu-list {display:none;}

- jQuery Code

$(".select-link").on('click',function(e) {     e.preventDefault();     $(".dropdown-menu-list").show(); })

$(document).mouseup(function (e) {     var container = $("YOUR CONTAINER SELECTOR");     if (! // if the target of the click isn't the container...         && container.has( === 0) // ... nor a descendant of the container     {         container.hide();     } });

jQuery split long ul list to multiple UL

1. HTML code

<ul id="bigList"> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem</li> <li>Elem<…

Scroll to bottom of image when mouse over

1. Css Code
<style type="text/css">             .image-bg {                 margin:0;                 padding:0;                 background-image: url("landingpage_07.jpg");                 background-repeat: no-repeat;                 display: inline-block;                 height: 344px;                 padding-top: 31px;                 position: relative;                 width: 457px;             }             .image-bg:hover .image-shop-scroll {                 background-position: center 100% !important;             }             .image-bg .image-shop-scroll {                 transition: all 5s ease-out 0s;             }             .image-bg .image-shop-scroll {                 background-position: center 0;                 background-repeat: no-repeat;                 height: 313px;                 left: 0;                 margin-bottom: 20px;                 overflow: hidden;                 position: absolute;                 width: 100%; …

Exclude weekends on jQuery datepicker

$('yourSelector').datepicker({ minDate:0,// your min date maxDate:'+1w',// one week will always be 5 business day - not sure if you are including current day beforeShowDay: $.datepicker.noWeekends // disable weekends});

Disable all Sundays in jQuery UI Calendar (datepicker)

$("#datepicker").datepicker({ beforeShowDay:function(date){var day = date.getDay();return[(day !=0),''];}});

Javascript random number between two numbers

function getRandomInt(min, max) {   return Math.floor(Math.random() * (max - min)) + min; } console.log(getRandomInt(1,100));

Javascript display numbers with commas

function commaSeparated(val){     while (/(\d+)(\d{3})/.test(val.toString())){       val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');     }     return val; } // Call Function console.log(commaSeparated(1)); // 1 console.log(commaSeparated(10)); // 10 console.log(commaSeparated(100)); // 100 console.log(commaSeparated(1000)); // 1,000 console.log(commaSeparated(10000)); //10,000

PHP: show a comma on all value except last value from mysql_fetch_array

$count = 0; while ($servdescarrayrow = mysql_fetch_array($servdescarray)) { if ($count++ > 0) echo ","; echo $servdescarrayrow['serv_desc']; }

PHP: Prepend leading zero before single digit number

It will only add the zero if it's less than the required number of characters.

When working with numbers, you should use %d (rather than %s), especially when there is the potential for negative numbers. If you're only using positive numbers, either option works fine.

For example:

sprintf("%04s", 10); returns 1000
sprintf("%04s", -10); returns 0-10

Where as:

sprintf("%04d", 10); returns 1000
sprintf("%04d", -10); returns 100

<?php $num =4; $num_padded = sprintf("%02d", $num); echo $num_padded;// returns 04?> You can use sprintf:

WordPress: Defined Home and Site Url

WP_SITEURL, defined since WordPress Version 2.2, allows the WordPress address (URL) to be defined. The value defined is the address where your WordPress core files reside. It should include the http:// part too. Do not put a slash "/" at the end. Setting this value in wp-config.php overrides the wp_options table value for siteurl and overrides the WordPress address (URL) field in the Administration > Settings > General panel when logging in using wp-login.php. It will _not_ update your Home url. Read more about this in depth in the link provided in the Note field:

WP_HOME is another wp-config.php option added in WordPress Version 2.2. Similar to WP_SITEURL, WP_HOME overrides the wp_options table value for home but does not change it permanently.home is the address you want people to type in their browser to reach your WordPress blog. It should include the http:// part and should not have a slash "/" at the end.

If you won't change the Database …

Email template: eDM SPECIFICATIONS


- Content must be supplied in HTML
- email body width: 600 pixels
- Total file weight (including HTML, CSS, images): 50KB
- We cannot accept emails built with CSS in the header tags or that include flash or forms!
- Use HTML tables for layout. Tables control the design layout and presentation.
- Use Standard Inline CSS. Do not design your HTML as a web page. Most web-based email clients strip Header CSS


- Explicitly define colour values as email clients may have different default colours which vary from web browsers.
- All image tags should include width and height attributes as stretched images will not render correctly in some email clients.
- <div> tags as the box model is not supported by a majority of e-mail clients and should be avoided. Tables should be used for e-mail layout. Also, avoid using rowspan as it won’t render consistently.
- It is recommended to set cellpadding and cellspacing to 0 on the table elients.
- Line-breaks (<br />) should be used i…

Email preheader best practices, Preheader email marketing and email preheader html

A preheader is a small section that appears at the top of your email. The following tips can help you make the most of the preheader in every marketing campaign  you develop.

Understand that the first line of your text is critical. It is this text that will appear when recipients access their inboxes from smartphones, tablets and other mobile devices.Know how to code the preheader properly. The preheader should convey the message of your email clearly and concisely.Use the preheader text to summarize your offer in a way recipients can easily understand.Keep things short and simple. Your recipients are busy, and they are probably looking through dozens of new emails every time they log on to their mobile devices.Use left alignment for your preheader text. This will make the text easier to read, especially on mobile devices.Use a standard easy to read font for your preheader text. Now is not the time to get too fancy.Include a clear call to action in your preheader text. Link your call…

Convert from MySQL datetime to another format with PHP

// $datetime is something like: 2014-01-31 13:05:59 $time = strtotime($datetimeFromMysql); $myFormatForView = date("d-m-Y g:i A", $time);// $myFormatForView is something like: 01/31/14 1:05 PM

PHP get Google News RSS Feed

If you know how to get the HTML data from the right XML-element (<description> in this case) you can just strip all HTML with PHP's strip_tags

This seems to work like you want it:

<?php $news = simplexml_load_file(''); foreach($news->channel->item as $item) {         echo "<h1>" . $item->title . "</h1>";     echo '<p>' . strip_tags($item->description) ."</p>"; } ?>