My goal is to see what the value of a particular vocabulary for a node is. In order to do this, I thought I would check the $node object in hopes that somewhere in that array would be the taxonomy values.

So I enabled the devel module and added the "Execute PHP" block to my sidebar. Then I opened a node page in the browser and typed in print_r($node) into the Execute PHP block. However, nothing was outputted. It's been a while since I've worked with drupal, but I thought that this worked. Am I missing something?

Thanks.

Comments

kevinquillen’s picture

var_dump($node);exit; in node.tpl.php.

I would advise hooking up with dBug to make your life easier in this manner.

You could also do var_dump($taxonomy) in node.tpl.php.

http://dbug.ospinto.com/

===========
read my thoughts

yelvington’s picture

Devel module adds node object inspection tabs. Use them.

sodani’s picture

var_dump($node); comes up as NULL. Even if I use the "Dev load" tab to inspect the node object, how do I actually access the node object within my code? I don't understand why it's not accessible in $node. I'm just showing up as NULL.

dman’s picture

$node is available to contexts that deal directly with it. like node.tpl.php

Running your code in a block will not automatically have access to the 'current node' because
- many pages are not 'node' pages
- some pages contain multiple nodes
- blocks may be cached differently from page content
- in processing, the block rendering and the node rendering happen in distant parts of the code, I'm not even sure which runs first.

ANYWAY.
Go see the PHP block snippets for clues on retrieving what is probably the current node being viewed when you are in a block php context,
if(arg(0)=='node' && is_numeric(arg(1)) { ...

It would be nice if there was a core-sanctioned way of just getting the 'current' node. Maybe there is...