Search This Blog

Monday, 14 January 2013

CSS Font-Size: em vs. px vs. pt vs. percent

Meet the Units

  1. “Ems” (em): The “em” is a scalable unit that is used in web document media. An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc. Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.
  2. Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
  3. Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.
  4. Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.
Click here for more information.

Wednesday, 9 January 2013

Add rel=next and rel=prev for all the paginated pages

Use the following code in your theme functions.php

    function rel_next_prev(){
        global $paged;
        if ( get_previous_posts_link() ) { ?>
<link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>" /><?php
        }
        if ( get_next_posts_link() ) { ?>

<link rel="next" href="<?php echo get_pagenum_link( $paged +1 ); ?>" /><?php
        }
    }
    add_action("wp_head", "rel_next_prev");

Get the post / page ID in functions.php

Usually the global variable $post will give the user all the information of the current post / page. This global variable is not available in functions.php (if the code is not in a function) so you can use the following code snippet to get the ID of the post/page ID based on current URL.

$currenturl = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$curpostId = url_to_postid($currenturl [0]);




$curpostId value will be zero if the current page is not a post / page.

Sunday, 6 January 2013

Cron Job in Magento

A few features in Magento require a script to be run periodically.  These features include, but are not limited to:


1. Catalog Price rules
2. Sending Newsletters
3. Generating Google Maps
4. Customer Alerts/Notifications (product price change, product back to stock)

Saturday, 5 January 2013

Save Core Config data prgramatically

$coreConfig = new Mage_Core_Model_Config();
$coreConfig ->saveConfig($path, $value, $scope = 'default', $scopeId = 0);
Mage::app()->getConfig()->reinit();
Mage::app()->reinitStores();