views:

365

answers:

4

In Drupal's page.tpl.php

<?php foreach($node->og_groups as $test) {dpm($test);} ?>

Gives me
alt text

But when I do

<?php foreach($node->og_groups as $test) {print($test);} ?>

The value doesn't show up. this is kinda frustating.. Any help is appreciated.

Cheers!

A: 

You can use

<?php foreach($node->og_groups as $test) print_r($test) ?>
451F
I did that too, no results.
logii
Well, you can use debugger like xdebug or zend debugger to examine this.
451F
+1  A: 

Try doing a view source on the rendered page; it may be going to the top of the HTML and may not be visible in the browser output.

Steve Michel
+3  A: 

As Steve Michel suggested: Try doing a view source on the rendered page; it may be going to the top of the HTML and may not be visible in the browser output.

Drupal first executes all code, collecting output into a variable. At the very end, this variable is print out. If you print or var_dump something in between, this will be at the very top of the output (since that's done before any of the regular content is printed).

You even figured out the answer: use drupal_set_message (for which dpm is an abbreviation I guess?) to insert text in a nicely formatted way, somewhere in the content part of the page rather than before the tag.

If you need to print out arrays, you can use dpm(print_r($array, 1)) -- the 1 argument makes print_r return the formatted output (and pass it to dpm) rather than printing it out directly.

Wim
Hey Wim, thanks for your input. I have already given up on this method I'm trying. But for your info: `dpm()` is actually the drupal module(http://drupal.org/project/devel/) version of Krumo(http://krumo.sourceforge.net/)
logii
A: 

You can do this:

$node = $variables['node'];

and then use it like a normal node.

Cheers.

MäN