Monthly Archives: January 2011

Automatically Stage All Deleted Files (Git)

Tab-completion is a really nice thing that we often take for granted. While working with Git I’ve found that it becomes inconvenient to stage (add for inclusion in the next commit) removed files using git rm path/to/my/file.php. Tab completion doesn’t

Tagged with: , , ,
Posted in Development

Hiding fieldsets in a form using hook_form_alter()

The following examples shows how to hide fields/fieldsets in forms using hook_form_alter(). I suggest using the devel module to determine how to target your field(s) or fieldset(s). You can add a dpm($form) to the function during development and testing.

Note that this will prevent

Tagged with: , , , ,
Posted in Development

Using Vimdiff with Git

​UPDATED: Check out “git difftool” which makes this process much cleaner (than the commands I previously had listed here). Basically, you can tell git what to use as a diff tool and it’ll let you do things like:

Here is how

Tagged with: , ,
Posted in Development

Introduction to FirePHP

FirePHP is a great tool for debugging PHP, and maintaining some level of control over your error handling. Also, it’s a great tool for getting information about your variables, objects, etc. while your PHP code is executing. FirePHP requires only

Tagged with: , , , ,
Posted in Development

Changing the Title of a Node Add/Edit Page

The following example shows one way of changing the title on add/edit pages for a specified content type. We’ll accomplish this using hook_form_alter() in a custom module.

I suggest using the devel module dpm() function, or just php print-ing the $form_id variable at

Tagged with: , , , , ,
Posted in Development

Automatically Change Links from Absolute to Relative

In this example I’m showing one way to quickly convert all a href and img src paths from absolute to relative. It’s quite a time saver, but I suggest committing your latest changes before trying anything here! If you aren’t

Tagged with: , , , , ,
Posted in Development

Cache-related WSOD! Help!

UPDATE: You can do this stuff with Drush (setting the variable with vset). It’s much faster! Well, you’ve probably all had a White Screen Of Death a time or two while dealing with Drupal or PHP. They can be very

Tagged with: , , , , ,
Posted in Development

Delete comments and disable commenting on all nodes of a particular content type

Please TEST these queries before running them on a live site! I do not want to be held responsible if something goes wrong. Here is how a colleague explained his situation (the solution follows): The trap is that if you

Tagged with: , , , ,
Posted in Development

Using Vim to generate HTML for syntax-highlighted code examples

Recently I was looking for a simple way to embed colorized code snippets into Evernote or VoodooPad. Both of these applications allow HTML-colorized text. I’ve seen a few websites that will generate the appropriate code, but I wanted something I

Tagged with:
Posted in Development

Using module_list() to show active Drupal modules

This code can be used in a custom module, a template.php file, or most easily in a block. This looks good in the header bar on a demo site, without a title, as you can see in the screenshot! The

Tagged with: , , , ,
Posted in Development