Adds a nodeapi hook that adds the variable $GLOBALS['globalnode'] containing attributes for a given node. Which attributes are displayed is determined in the GlobalNode settings.

Sometimes it's useful to have information about a node in a scope that doesn't have access to the node by default. For example, in the block administration, you can write logic to determine when to display a given block. If you want a node to show up on all blog content, you need a rule that will catch instances where the uri is "/blog/", "/blog/some-title", and "/node/1234". The only way to catch "/node/1234" is to know the node type; else you might display the sidebar for other node types. As far as I've been able to tell, this information isn't easily gotten from the scope of the block display code.

Enter GlobalNode, which adds a nodeapi hook that adds the variable $GLOBALS['globalnode'] containing attributes for a given node. Which attributes are displayed is determined in the GlobalNode settings. In the example given above, I specify "type". This is then stored as $GLOBALS['globalnode']->type, which I can use in the block administration logic to show a sidebar for all nodes of type "blog".

There used to be in Drupal a global variable named $global_cache that could be used similarly, and this module does essentially what that variable did.

Example Usage:

<?php
 
if(($GLOBALS['globalnode']->list == false && $GLOBALS['globalnode']->type == 'blog') || preg_match('/^\/blog\/?/', $_SERVER['REQUEST_URI'])){
    return
TRUE;
  } 

?>

The block above demonstrates a potential usage. The "list" attribute is set to false by default and true when hook_nodeapi runs more than once (e.g. when there's more than one node, as in list views). This lets you dictate different behaviors for list views than for page views.

Downloads

Recommended releases

Version Downloads Date Links
5.x-1.1 tar.gz (6.97 KB) | zip (7.45 KB) 2007-Jun-28 Notes

Development releases

Version Downloads Date Links
5.x-1.x-dev tar.gz (6.89 KB) | zip (7.36 KB) 2011-Feb-25 Notes

Project Information


Maintainers for GlobalNode

  • dllh - 4 commits
    last: 4 years ago, first: 4 years ago

Issues for GlobalNode

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports