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() {
    $("p.animate").animate(
            {"height": "100px", "width": "250px"},
            "slow", function(){
                $(this).html("Animation Completed");
            });
});

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

<?php
    $view = views_get_current_view();
 
    $args = $view->args;
 
    drupal_set_title($args[0]);
 
 
    // 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
                $(this).css({'padding-top':mh});
 
                // for debugging
                console.log('a position: ' + i + 
					'a height: ' + ah + 
					'li height:' + ph +
					'p

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

<?xml version="1.0"?>
<config>
  <menu>
    <tutorial_menu translate="title" module="custompricing">
      <title>Custom Pricing Reports</title>
      <sort_order>9999</sort_order>
      <children>
        <first_page module="custompricing">
          <title>Our First Page</title>
          <action>custompricing/index/index</action>
        </first_page>
      </children>
    </tutorial_menu>
    <system>
      <children>
        <another_menu_from_us>
          <title>Here Too!</title>
          <sort_order>9999</sort_order>
          <action>custompricing/index/ind