Drupal coder

Panic Coda Drupal snippets (clips)

I've been using Panic's Coda as my default editor/IDE for some time now. I've already shared the Drupal plugin I wrote on this blog. But one of the other tricks Coda allows me to do is snippet management using its Clips feature. There's quite a few Coda clips available on the net. Here I am sharing the Clips I use the most during Drupal development and theming.

Download the package and develop faster yourself. There's something for everyone in it...

Some general usage snippets

  • Create a module.info skeleton.
  • Set the active menu item. Kind of what Menu Trails module does.
  • Show all regions on 404 "page not found" errors.
  • Delete all nodes.
  • CCK imagefield import script.
  • Submit and validation handler.
  • drupal_add_css
  • Get breadcrumb from active menu. Kind of what Menu Breadcrumb module does.
  • Drupal hooks

    Of course I have some snippets for the most used Drupal hooks. All of these have a tab trigger. For example hook_perm can be inserted by typing hook_perm and pressing TAB.

    In the package are hook_perm, hook_menu_alter, hook_init, hook_nodeapi, hook_menu, hook_cron, hook_boot, hook_flush_caches, hook_form_alter, hook_block, hook_theme, …

    Drupal fields

    These are probably the ones I use most often. Snippets for these elements: hidden field, textfield, submit button and select field.

    Some jQuery

    • Open links in external window.
    • Open pdf in new window.
    • Clear default values. Small plugin to clear default values from form fields when someone clicks them to start entering text.
    • $(document.ready)
    • Sticky footer.
    • Views row links hover. When you hover over a link in a .views-row the surround .views-row diff gets "active" too.

    PHP snippets

    • Function to generate a slug.
    • print_r : Just type print_r and hit TAB to get a formatted print_r : print "
      ".print_r(, TRUE)."


      . Perfect for quick debugging.
    • switch control statement.
    • Curl request

    CSS snippets


    The obligatory "Lorem ipsum" snippet. Just type lorem and hit TAB and get a lorem ipsum snippet.

drupal-coda-snippets.zip12.17 KB
February 04, 2010


Go ahead ;) I'll have a look myself too.

Hey, we should try and consolidate some of this stuff! :)


Here's a snippet for a Theme .info file:
; $Id$
name =
description = "The description of this theme"

; Screenshot in appearance overview
screenshot = screenshot.png

; Required core version (Drupal 6+; no effect in Drupal 5)
core = 6.x

; Required. Most themes should use "phptemplate" as the default engine.
engine = phptemplate

; Base theme, allows for theme inheritance, meaning the resources from
; the "base theme" will cascade and be reused inside this sub-theme
; base theme = garland

; Block regions
; regions[theRegion] = The region name.

; PHP version requirement (Drupal 6+)
; php = 5.2

; Features
; features[] = logo
; features[] = name
; features[] = slogan
; features[] = mission
; features[] = node_user_picture
; features[] = comment_user_picture
; features[] = search
; features[] = favicon
; features[] = primary_links
; features[] = secondary_links

; Stylesheets
stylesheets[all][] = style.css

; Scripts
scripts[] = script.js

; For further information about configuration options, see
; - http://drupal.org/node/171205 (Drupal 6)

Interesting. Well i will do the same with eclipse then.