Hang on...

Latest Stuff

Magento Get Customer and Address details

Chek customer login status:
Mage::getSingleton('customer/session')->isLoggedIn()

Get the customer object:
Mage::getSingleton('customer/session')->getCustomer()

Load formatted address:
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
if ($customerAddressId){
  $address = Mage::getModel('customer/address')->load($customerAddressId);
  $htmlAddress = $address->format('html')
}

Load and print address field values:
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling();
if ($customerAddressId){
  $address = Mage::getModel('customer/address')->load($customerAddressId);
  echo "<pre>"; print_r($address->getData());echo "</pre>";
}

Load single address field value:
$street = $address->getData('street');

Insert dynamic links into Magento wysiwyg editor to set store id

Linking to other cms pages from Magento's wysiwyg editor is simple, but if you don't know how to do it, you will get a few suprises.
The correct way to create a link is to wrap the url into a magento handler like this:

<a href="{{store url='cms-page-url'}}">CMS Page Title</a>

To link directly to the front page, simply leave the url empty.

<a href="{{store url=''}}">Front Page</a>

Add Static Block to Magento cms Page by updating the Design Layout XML

This is a very simple task.
Once you created the Static Block, simply go to CMS -> Manage Pages. Select your Page or create a new one.
Click on the Design tab on the left and paste the following code to the "Layout Update XML" textarea.
(Also, don't forget to select the Layout, eg.: 2 columns with left (or right) bar)

<reference name="left">
    <block before="-" name="block-name" type="cms/block">
        <action method="setBlockId"><block_id>block-id</block_id></action>
    </block>    
</reference>

The reference name can be left or right depending on which column you would like the block to appear.
The block name can be the same as the id. The block id is of course the Identifier of the block.
You can also set the position of the block by changing the before (or after) options in the block tag.
Once you saved the page, the block should show up in the sidebar.

This has been tested in Magento 1.6, but it should work in almost all the other versions.
Good luck.
 

7 Tips for a More Engaging Website

Dr. Susan Weinschenk shares seven principles beyond usability to make your website more engaging - principles of persuasion, emotion, and trust...

TAR compress, extract, bzip2, gzip

This is a note about how to tar and un-tar files. It serves as a memo as I always forget these commands and have to look them up.

Create a simple tar file:
tar -cvvf archive.tar folder_to_archive/

Extract a tar file:
tar -xf archive.tar

Bzip2 compress folder and it's sub folders, files:
tar -c --bzip2 -f archive.bz2 folder_to_archive/

Bzip2 extract:
tar -jxvf archive.bz2

Gzip compress folder and it's sub folders, files:
tar -cvzpf archive.tar.gz folder_to_archive/

Gzip extract:
tar -zxvf archive.tar.gz

Extract Gzip SQL:
gunzip archive.sql.gz

Google Apps MX record validation hangs. How to fix?

As usual, this is just a quick article about how to fix your domain alias in Google Apps when MX validation can not complete.
If you created a new domain alias in Google Apps, verified that the domain belongs to you and set up the MX records based on the instructions you should be good to go. Unfortunately this is not always the case. Sometimes the MX record validation hangs and never completes. This is what you can try:

1) Remove the domain alias
2) Re-add the alias - Google will tell you that you already validated that domain. If you validated using the DNS settings, do not remove the validation code after validation.
3) Add the MX records based on the instructions. Try using the default settings where possible.
4) Re-validate the MX records

This should solve the issue and your MX records should be validated instantly.

How to root Tabtech M009S + some info

This is a quick quide on how to root the Tabtech M009S Android tablet.

Device info:

Android 2.2, Kernel: 2.6.32, Build: 1.3.0

Go to this page and download the latest version of z4root:
http://goo.gl/Tc8fi

Install and run z4root. Select the "Permanent root" option.
Wait until the up finishes and restarts your device.

Once the devices rebooted, you should have the superuser app available in the menu.
The busybox app also been installed although it won't show up in the app list.

Use terminal emulator (download it via market) to be able to use the su command.
If you get the "must be suid to work properly" error, cd into "/system/bin" and use the following
command to start su "./su" and then "su" again. Check the user using "whoami".

Some additional info which migh come handy if you are planning to by one of these tables:

Please note that altough the Tabtech M009S comes with preinstalled Skype, it won't work over Wifi.
The Google Android Market doesn't offer a lot of apps normally available on the UK Market.
Market Enabler doesn't work on this device as the device has no sim card.
The touch screen is not multitouch but the old resistive type. (You get a stylus with the tablet.)
Screen is 800×480 and some applications will run very slow because of the size of the screen.
The camera is 0.3 megapixel and it's front facing.
The devices is capable of connecting to Wifi via it's built in Wifi module.
You have to use an external 3G dongle to be able to connect to 3G.
You can connect USB flash drives to the tablet. (I am not sure if there is a size limit.)
You can also connect a USB keyboard and mouse. (It's fun!)
Flash is supported but it is very limited and slow. If you set the Dolphin Browser's User Agent to Desktop, you can watch youtube videos.
Tabtech M009S is capable of playing avi videos and the usual 3gp format.

That's it for now. I will post again, if I find anything else worth mentioning. :)
Questions are welcome.

jQuery Change select dropdown value and remove selected attribute

Again, this is just a quick note about how to select an option with jQuery and remove the selected attribute.

$("#id-select :selected").removeAttr("selected");
$('#id-select').val('[value you need to select]');

As you can see, it is not enough just to select a new value using .val() because the selected attribute will stay on the form item and when you submit the form, the old value will be used.

drupal_alter() example

This is a quick article about the drupal_alert() function using pathauto as an example.

In pathauto.inc, there is a drupal_alter('pathauto_alias', $alias, $context) call, so we can implement our own function to alter the alias generated by pathauto.

In our example module we need to create a new function, where the first part of the function name is the module name, "example_module", the second part is the string, "pathauto_alias", used in the drupal_alert call and the third part is the hook name, "alter". Arguments are (for Drupal 6) $data and $context.

 
/**
 * Implementing drupal_alter() hook to override pathauto alias
 */

function example_module_pathauto_alias_alter($data, $context){
 // you can do stuff with the data. No return required as $data is passed in by reference.
}

That's it. It is not very complicated. :)

VirtualBox 4.0.4 released - maintenance only

This is a maintenance release.

You can find the latest  VBoxGuestAdditions ISO (4.0.4) here:

http://download.virtualbox.org/virtualbox/4.0.4/VBoxGuestAdditions_4.0.4...

Don't forget, you can install Virtualbox using the Update Manager in Ubuntu:

Add the following line to the /etc/apt/sources.list: (for latest 10.10 Ubuntu - older versions, change distro name in url)

deb http://download.virtualbox.org/virtualbox/debian maverick contrib

The Oracle public key for apt-secure can be added using these commands:

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

Finally, simple run the update command and install Virtualbox

sudo apt-get update

sudo apt-get install virtualbox-4.0

From now on, the Update Manager should pick up all the updates for Virtualbox.

Drupal 6 Override Post new comment text for a single content type

If you would like to change the "Post new comment" text on just a single content type copy paste this code into your template.php, change the function name to your theme name and set the content type. The str_replace function second parameter will be your new text.

function YOUR_THEME_NAME_comment_wrapper($html, $node) {
  if($node->type == 'YOUR_CONTENT_TYPE'){
    $html = str_replace('<h2>Post new comment</h2>', '<h2>Post new reply</h2>', $html);
  }
  return $html;
}

Tested in Drupal 6.

Friendly and powerful: Drupal 7

Drupal 7 is out now. Visit this page for more info: http://drupal.org/7

We are proud to present to you our best work yet – Drupal 7, the friendly and powerful content management platform for building nearly any kind of website: from blogs and micro-sites to collaborative social communities.

Drupal 7 Marketing Video from Jeff Robbins on Vimeo.