0

I am relatively new to Drupal. We have a site and I've been asked to jump in and make some changes. I'm working on customizing the output of the Webforms module. I'm having trouble doing so because I can't seem to find a reference to the various data structures Webforms uses.

For example, I need to change something in a preprocess hook. Passed into the hook is a structure called $variables. I can see that attributes are being added to the piece I want to change, so I know I'm in the right hook. What I want to do is add something to the text. But I can't figure out where in $variables the text is so I can change it.

I'm sure what I need to change is in there, but I can't seem to get at it. All the documentation I've found on the web is either "paste this code in" or assumes you know the data structures.

So:

1. Is there a reference anywhere to these structures? $variables is one. $submission, $components are others. There are probably more. I know their contents vary widely with the specific webform, but looking for a general reference.

2. How can I see the contents of one of the structures from inside a hook? I've tried a lot of things, but no luck. Would be great to either have it output to the Apache log, or show up on the screen, something...

Any help would be greatly appreciated. It feels like there's real power here, but I can't get at it because I'm missing some basics.

1 Answer 1

1

I would say you need to install 2 modules to figure out what is going on...

First Devel, allowing you to use the dmp function. This will output a whole array to the message area.

And then my new favorite module, Search Krumo.

A webform is generated from large array of data and finding the bit that is relevant to you can often be difficult just looking though the dmp output. Search Krumo puts a search box in the message area allowing you to search for any instances of a string in the whole array structure. When you've found the bit that is relevant it also lets you copy the path to that array element so you can easily modify values buried deep in multi-arrays.

EDIT:

If you don't want the output on the screen but would rather log it then use Devel Debug Log. Very useful for debugging ajax requests etc.

If you just need to log simple strings not whole arrays then the dd function is useful combined with: tail -f /tmp/drupal_debug.txt assuming you have SSH access.

Sign up to request clarification or add additional context in comments.

2 Comments

Those were already installed and using them has helped a lot. There are some situations where it would be good if their output couple send to a file or the log, when the page is changing and other times when the putting it on the page is not practical. Thanks for the help!
@DanBarron I've just updated my answer with a way to log that data.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.