Blog

Quick Tip: Dive Into Drupal Objects with Search Krumo

Written by Metal Toad Staff | Sep 13, 2012 12:00:00 AM
Filed under:

If you've done any signifigant development with Drupal, you're probably (deeply) familiar with a little function called dpm(). I think it stands for Drupal Print Message. If you aren't familiar, dpm() is available through the Devel module and it's a great tool to dive into any Drupal code you might be working with. You can examine available variables, the node object, etc. It even prints out in a nice compact bundle in the 'Messages' area.

A few months ago, Dylan sent out a message about a module called Search Krumo and it changed my dpm()s forever. ::sniff::

Let's say you need to dig into a form and grab an element from it. Form DPMs can get pretty deep. By the time you dig into to the array inside the array inside the object you can easily lose track of where you are.

But after downloading the Search Krumo module you can add the magic 's': sdpm($form). Now you get a search box at the top of your output. Search terms will be highlighted, and when you find what you're looking for, there's a handy 'Get Path' feature so you can just copy the syntax to reach the element and paste it into your code.

So easy! The worst thing about Search Krumo is that I didn't know about it sooner. Happy developing!