Coldfront Labs

08/04/2010 - story

Drupal Quick Tip #11: dsm (Drupal Set Messsage)

If you've ever written a module before you must be familiar with the "drupal_set_message" function in core. It's a nice way to write messages to the screen (either as notices, errors or warnings). But say you want to print an array to the screen and see the values, can't really be done that easily (unless you use a print_r but who wants to do that). With the Devel module, you gain a function called dsm() (short form for drupal_set_message). Not only is it shorter to type, but you can put arrays, objects, whatever as a parameter and using the Krumo library. So things come out in nice blocks that you can drill down into. Here's how.
What you'll need: Devel module
How to do it:

  1. Install and enable Devel
  2. Add the calls to 'dsm()' into your code

Now you can look at your arrays and objects in style!

08/03/2010 - story

Drupal Quick Tip #10: Avoid critical errors when demoing development code

Inevitably during your development process, the client is going to want to see how things are going. And typically in these cases you don't want to demo on the actual development environment. So you setup a test site to demo everything which may or may not contain all those lovely Drupal development modules (i.e. coder, devel, etc...). And if that's true, what if there are stray 'dsm' calls in your committed code? I mean it's safe to assume you grabbed a copy from your repo which is still under active development so it's safe to assume there's some dev code in there. And that code will cause critical errors with those dev modules missing. The last thing you want is to show big error pages during a demo!

Now I know this is a lot of if's but it could happen (trust me...). Here's how to avoid it:

What you'll need: Your fingers and cooperative developers

Syndicate content

Latest Tweets

  • #dcsf picture time! 19 weeks 4 days ago
  • What kind of team building stuff do you do remotely? (since not everyone is local) #magicteams 19 weeks 4 days ago
  • Really enjoying Drupalcon, learning so much! Need time to digest the info....and the awesome food! 19 weeks 5 days ago
  • Holy crap! http://tinyurl.com/yycqls6 Live NHL games on Boxee :-D #iamcanadian 20 weeks 16 min ago
  • Just getting to my second session at #dcsf and I've already lost my pen :-S 20 weeks 17 min ago

Poll

Do you plan on switching to Drupal 7 when it's released?:
Copyright © 2010