NailThumb – A jQuery plugin to create thumbnails easily

NailThumb is a new jQuery plugin to create thumbnails from high-res images, without any distortion, with one line of jQuery code. This plugin processes thumbnails dynamically on the client side, without using any server side scripting like PHP or ASP.NET, few lines of jQuery code and it will generate thumbnails for any images.

It Integrates perfectly with any media gallery, even more useful in dynamic web application when you can face any shape or size. If you want to add avatars to your application it’s easier to use this plugin to let them fit any size you need then to develop a functionality that help your user to upload avatars of the right size/sizes.

Their website has a proper documentation on how to implement this in your website, and what all methods and options it supports. They also have a live demo of this plugin which you can use to see what all special features and functionalities this plugin provides.

I think this can be a useful plugin for website where there are galleries or heavy image work. This tool can help user to re-size the image on client side, so from first look this looks a very useful plugin to me.

Category → jQuery
Tags → ,
Comments → 1 Comment

netrenderer – An online tool to test your website in all versions of Internet Explorer

netrenderer is free and new tool to test your website rendering & display in different versions of Internet Explorer. This tool allows you to check how a website is rendered by Internet Explorer 10, 9, 8, 7, 6 or 5.5. Just type in a URL in the field given on their website and try it out. This tool generates screenshot of your website rendered in IE browser; this tool is also faster than other similar tools.

With the introduction of latest and modern browsers like Google Chrome and Firefox, the popularity of Internet Explorer is down and but that is due to a valid cause or reason. Because IE doesn’t support lot of modern technologies also it doesn’t render website same as other browsers, it walks on his own path and render website differently than other browsers.

As a developer IE is always pain for me, but as it exists in the market and is the major browser of windows platform, which makes it necessary for us to test our website and web applications in IE. IE9 is a lot better than other version of IE but still there are lot of people uses IE6, 7 and 8 and which why we need to test websites in IE6, 7 and 8 to ensure proper rendering and display.

I am using Windows 7 and it has IE9 by default, and I think this tool is useful for me. But I usually use IE Tester, a free tool which you can install in your system and with this you can test your website in IE.

Overall netrenderer is a better tool for people who use other similar online services to test their website in IE, it is fast and free.

Category → Tools
Tags → , ,
Comments → Leave a comment

Create a dropdown menu using CSS3

Recently I used twitter bootstrap library and found that there are many new CSS3 elements used in it like gradient, transition etc. I thought to use them in my dropdown menus, I know these CSS3 effects doesn’t work properly in IE6, 7 and 8 but IE9 supports some features of CSS3 and I am sure IE10 will fully support CSS3. We will design the dropdown menu in a way so that it will render and display properly in IE6, 7 and 8, it will not support CSS3 features but will work in those browsers.

I tried not to use the JavaScript code in my menu, which makes it pure CSS/HTML based menu. Also there are no images in it; I achieved the gradient effect and other effects shown in menu using CSS3 properties.

HTML
We need following HTML for menu, you can change the menus according to your need.

<ul class="navbar">
 <li><a href="#">Dashboard</a></li>
 <li>
 <a href="#">Posts</a>
 <ul>
 <li><a href="#">All Posts</a></li>
 <li><a href="#">Add New</a></li>
 <li><a href="#">Categories</a></li>
 <li><a href="#">Tags</a></li>
 </ul>
 </li>
 <li>
 <a href="#">Media</a>
 <ul>
 <li><a href="#">Library</a></li>
 <li><a href="#">Add New</a></li>
 </ul>
 </li>
 <li><a href="#">Links</a></li>
 <li><a href="#">Pages</a></li>
 <li><a href="#">Comments</a></li>
</ul>

CSS
We require following CSS to achieve those effects and dropdown menu function.

/* reset the navbar area */
 .navbar,
 .navbar ul,
 .navbar li,
 .navbar a {
 margin: 0;
 padding: 0;
 border: none;
 outline: none;
 }

 /* navbar style */
 .navbar {
 height: 40px;

 background:#599F2F;
 background:-moz-linear-gradient(top,#9FE355 1px,#79BF4A 1px,#599F2F);;
 background:-webkit-gradient(linear,0 0,0 100%,color-stop(0.02,#9FE355),color-stop(0.02,#79BF4A),color-stop(1,#599F2F));
 color:#FFFFFF;

 -webkit-border-radius: 5px;
 -moz-border-radius: 5px;
 border-radius: 5px;
 }

 .navbar li {
 position: relative;
 list-style: none;
 float: left;
 display: block;
 height: 40px;
 }

 /* style of links under navbar */
 .navbar li a {
 display: block;
 padding: 0 14px;
 margin: 6px 0;
 line-height: 28px;
 text-decoration: none;

 border-left: 1px solid #53962A;

 font-weight: bold;
 font-size: 13px;

 color: #fff;
 }

 .navbar li:first-child a { border-left: none; }
 .navbar li:last-child a{ border-right: none; }

 .navbar li:hover > a { color: #BDE8A2; }

 /* sub nav styles */
 .navbar ul {
 position: absolute;
 top: 40px;
 left: 0;

 opacity: 0;

 background:#599F2F;

 -webkit-border-radius: 0 0 5px 5px;
 -moz-border-radius: 0 0 5px 5px;
 border-radius: 0 0 5px 5px;

 -webkit-transition: opacity .25s ease .1s;
 -moz-transition: opacity .25s ease .1s;
 -o-transition: opacity .25s ease .1s;
 -ms-transition: opacity .25s ease .1s;
 transition: opacity .25s ease .1s;
 }

 .navbar li:hover > ul { opacity: 1; }

 .navbar ul li {
 height: 0;
 overflow: hidden;
 padding: 0;

 -webkit-transition: height .25s ease .1s;
 -moz-transition: height .25s ease .1s;
 -o-transition: height .25s ease .1s;
 -ms-transition: height .25s ease .1s;
 transition: height .25s ease .1s;
 }

 .navbar li:hover > ul li {
 height: 36px;
 overflow: visible;
 padding: 0;
 }

 .navbar ul li a {
 width: 100px;
 padding: 4px 0 4px 14px;
 margin: 0;

 border: none;
 border-bottom: 1px solid #53962A;
 }

 .navbar ul li:last-child a { border: none; }

That’s it, we simply need HTML and CSS code to create dropdown menu bar. I have included all CSS and HTML code in one single file, you can see the DEMO HERE

This dropdown menu works fine in Firefox, Chrome and other modern browsers. It doesn’t work in IE6 but works fine in IE7 and 8 without CSS3 effects. In IE9 it supports some CSS3 effects.

If you have any problem in understanding the CSS or HTML code, you can ask it to me by adding your comment blow. I will try to sort out your problem. Thanks.

Category → CSS
Tags → , , ,
Comments → Leave a comment

Length of TEXT datatype in MySQL

I faced a problem related to length of TEXT datatype in MySQL, there was a column of TEXT datatype in my database table, I thought it will store large data easily, but when I was trying to store a data of more than 65,000 characters then it was only taking about 65,000 characters and stripping the rest. I checked and found that TEXT type columns in MySQL can store only 65,535 characters data and which is why I was facing that problem. So I thought to write and share this post.

TEXT datatype columns can store string (alpha-numeric) data in tables and hence TEXT datatype falls under String Types in MySQL. MySQL supports 4 types of TEXT field types, all varies in terms of length of characters they can store. All 4 types of TEXT field types in MySQL and the amount of data they can store are listed below:

  1. TINYTEXT – 256 bytes
  2. TEXT – 65,535 bytes (64 KB)
  3. MEDIUMTEXT – 16,777,215 bytes (16 MB)
  4. LONGTEXT – 4,294,967,295 bytes (4 GB)

In case of TEXT datatypes, information or data is stored internally in a different area of memory than the row buffer. Different storage engines (such as MyISAM, InnoDB) handle the allocation and storage of this data in different ways, according to the method they use for handling the corresponding types. Particularly in case of MyISAM tables, they can store maximum of 65,535 bytes in a row, which means data more than that is stored and handled separately in memory.

TEXT datatypes are useful to store large amount of data, but if your data is small then try to use VARCHAR instead, unnecessary use of TEXT datatypes in column can make processing of table slow and hence it will affect the performance of operations between database and your web application. Also, use MEDIUMTEXT or LONGTEXT if really required and you are sure that data will be that much large to have these columns.

Try to avoid TEXT datatype instead use of VARCHARs is better but all depends on your applications requirements.

Category → MYSQL
Tags → , ,
Comments → Leave a comment

Show single special offer product order by highest special price in magento

In an e-commerce site I am working these days, there was a requirement to show a single special offer product on home page, order by highest special offer price. This means, out of all special offer products we have in our catalog I need to show one product on home page.

For example, if I have 5 special offer products in my catalog with special price $1, $6, $3, $4 and $2, then product with special offer price $6 will be displayed on home page.

To fetch single special offer product, I used following code on my home page .phtml file.

<?php
$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d')+1, date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);
$collection = Mage::getResourceModel('reports/product_collection')
 ->addAttributeToSelect('*')
 ->addAttributeToFilter('visibility', array('neq'=>1))
 ->addAttributeToFilter(
 'status',
 array('neq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
 )
 ->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
 ->addAttributeToFilter('special_to_date', array('or'=> array(0 => array('date' => true, 'from' =>$tomorrowDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')
 ->setPageSize(1)
 ->addAttributeToSort('special_price','desc');

$collection->load();
foreach ($collection as $product)
{
 $result[] = $product->getId();
}
foreach ($result as $_product_id)
{
 $_product = new Mage_Catalog_Model_Product();
 $_product->load($_product_id);
?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>">
 <img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(140); ?>" width="140" height="140" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
</a>
<?php
}
?>

Using the above PHP code, you can show a single special offer product on your home page. Please modify the rendering HTML of foreach loop as per your page requirement.

Category → Magento, Tips
Tags → , ,
Comments → Leave a comment