The new Google

By: Arshad

22 Mar 2010

Is this the new Google?

Check out a larger image here.

Update : you can access the new google homepage if you are on ubuntu. It works with the latest beta version of chrome only. Screenshots :

Theming the drupal username

By: Arshad

22 Mar 2010

If you look a drupal node, drupal displays the author of this node as the username of the user or anonymous if the author is not registered user. Now if we want to display the real name of the user (a field we will add in the profile module) instead of the username, drupal provides a theming function that let's you modify the output of the username before it is printed on a node. Let's see how we can do this.

Most of us have more than many functions in our template.php file. Hooks and preprocess function to make our site look as good as the designer did it. In many cases where a site requires advanced theming,the template.php file gets huge. To keep a structured and clean coding style consider using file includes. This way you can have codes in seperate php files loaded into template.php during execution.

This is a very similar approach to how Drupal core calls files from the "includes" folder.

Here's the code to include files :

An alternative to print_r in Drupal

By: Arshad

20 Mar 2010

How many times do we use a quick print_r to see what's in $node or $result or anything else? When coding modules , it's not very easy to output data structures to the screen unless you do a print_r($node) and view the source code. or do it like this :

[php]<pre><?php print_r($node); ?></pre>[/php]

Here's a clean and simple way you can output such data on screen. If you have the developer module enable (devel), use the dsm() (drupal_set_message) function.

Unique class for list items in drupal

By: Arshad

19 Mar 2010

I'll go directly to the code

This one goes in your template.php (under sites/all/themes/yourtheme/).

  1. function phptemplate_menu_item_link($link) {
  2. if (empty($link['localized_options'])) {
  3. $link['localized_options'] = array();
  4. }
  5. if (empty($link['localized_options']['attributes']['class'])) {
  6. $link['localized_options']['attributes']['class'] = 'menu-'. $link['mlid'];
  7. }
  8. else {
  9. $link['localized_options']['attributes']['class'] .= ' menu-'. $link['mlid'];
  10. }
  11. return l($link['title'], $link['href'], $link['localized_options']);
  12. }

How to check for javascript errors

By: Arshad

19 Mar 2010

There are time when CTRL+SHIFT+J tells you no error found. Still your fancy scripts won't load on internet explorer. After killing the whole day trying to figure out you decide to scrap everything and restart or even remove the whole javascript from the site..In time like that JSLint is the tool you need.

Simply copy and paste your javascript in on the site homepage. It will automatically check for JS errors.

Google Wave Free Invitations

By: Arshad

19 Mar 2010

I still have about 23 wave invitations left. anyone with a gmail account reply to this post i'll invite you. ;)

There are three ways of centering an element on a page: using margins, using percentages, or using absolute sizes in css. The first method seems to work better for most. But unfortunately, Microsoft Famous Internet Explorer for Windows - has a fairly serious bug regarding the treatment of block level elements and margins. So here's a jquery plugin that solve this problem with ease.

Firefox 3.6 is out

By: Arshad

22 Jan 2010

Willaim Reynolds, Firefox Campus Rep Head

Upgrade to Firefox 3.6Firefox 3.6 logo

This week we are super excited about the release of Firefox 3.6!

Our best version of Firefox is officially ready for you to download! What's new in Firefox 3.6? Lots!

Styling active anchor with jquery

By: Arshad

17 Jan 2010

Snippet to add a class to the current active link for styling with css.

  1. $(document).ready(function(){
  2. //set class active-anchor to active anchor
  3. $('a').each(function(){
  4. if($(this).attr('href')==window.location.search)
  5. $(this).addClass('active-anchor')
  6. });
  7. });

There you go. Now the anchor that points to the current page will have the class active-anchor. You can style it in you css using .active-anchor.

About Me

Arshad Chummun Hello I'm Arshad. I'm a 21 years old Drupal Web Developer. This is a site i put up for some reasons i can't remember and this is where i write stuffs i need to remember.;)

In the Web world, i head the Drupal Mauritius User Group and the jQuery user Group Mauritius and i'm a campus representative for Mozilla Firefox. 

DrupalCon CPH 2010

Copenhagen August 23 -27

Drupalcon CPH 2010