February 2012

jQuery animate() Example with Callback Function

Use a callback function to display a message once the animation is completed. This snippet will animate every

html element and then replace the html with the message when the #link-id element is clicked.

$("#link-id").click(function() {
            {"height": "100px", "width": "250px"},
            "slow", function(){
                $(this).html("Animation Completed");

Drupal Views Title from Argument - Use Views Argument as Page Title

    $view = views_get_current_view();
    $args = $view->args;
    // if argument is taxonomy
    // $termObject = taxonomy_get_term($args[0]);
    // drupal_set_title($termObject->name);

How to Uninstall a Module in Magento - Reinstall Magento Module and Run Install Script

If you want Magento to reinstall the module and re-run any database setup, take a look at the core_resource table.

Delete your module from this table and DROP any tables that the module had created. Clear Magento’s cache and the module will re-install.

The mysql4-install-X.X.X.php files will only be run once by Magento. By changing the version value in your XML config (Namespace/Module/etc/config.xml), you’re telling Magento which install file it should use:

Vertically Align an Element with jQuery - Vertical Align an Anchor or Div

//align text vertically
var i = 1; // for debugging
$('div.view-home-colored-circles div.view-content ul li a').each(function(){
		var ah = $(this).height();
                // insert the element/id/class to center within
		var ph = $(this).parents('li').height();
		var mh = Math.ceil((ph-ah) / 2);
                // may choose to use margin-top - depends on your case
                // for debugging
                console.log('a position: ' + i + 
					'a height: ' + ah + 
					'li height:' + ph +

Add a Link to Admin Menu or Sub-menu in Magento Module

<?xml version="1.0"?>
    <tutorial_menu translate="title" module="custompricing">
      <title>Custom Pricing Reports</title>
        <first_page module="custompricing">
          <title>Our First Page</title>
          <title>Here Too!</title>