Quick Tip: Dive Into Drupal Objects with Search Krumo

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.

Example of dpm() run on a node

Diving into a node with dpm

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.

Example of dpm with search krumo module

Example of dpm() get path feature

dpm with exposed path

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

Comments

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Ready for transformation?