Drupal

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.


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.

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!

Similar posts

Get notified on new marketing insights

Be the first to know about new B2B SaaS Marketing insights to build or refine your marketing function with the tools and knowledge of today’s industry.