Accessing the current node information and the current user information in Drupal
This is a very common question in the Drupal forums, one that I have often had to look up when I am working on a project: "How do I access the current node information from the within the node that I am on?".
Like wise, a similar question is " How do I access the current user information so that I can say something like: 'Welcome, *username*! Thanks for visiting our site!' ?"
<?php
global $user;
drupal_set_message("". var_export($user, TRUE) ."
");
if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
$node = node_load(arg(1));
drupal_set_message("".var_export($node , TRUE)."
");
}
?> - johnvsc's blog
- Login to post comments
