In the hook_page function of a .theme, how can I get the current $node?

Also, hook_page isn't showing up when I search for it in the api. Am I doing something wrong?

http://api.drupal.org/apis/HEAD/hook_page

Comments

dldege’s picture

Not sure where you are wan'ting access to the node.

When themeing a node you have direct access to it in your node.tpl.php file as $node.

In your template.php you can get it at various stages.

For example in

function _phptemplate_variables($hook, $vars = array()) {
}

You can access $vars['node']

dLd

styro’s picture

I assume this a pure PHP theme and not xtemplate or other engine theme? I'm only really familiar with phptemplate themes, and these days you need a very good reason not to use phptemplate themes.

As far as I know there is no hook_page. Any module that does have a modulename_page function isn't using it as a hook but rather as a hook_menu callback or other function.

With a pure PHP theme, you will be overriding this themable function for your pages:

http://api.drupal.org/api/HEAD/function/theme_page

Notice that the only parameter passed to it is the rendered HTML content.

Pure PHP themes don't have all the phptemplate engine goodness like template variables etc. What you would probably need to do is add some code to theme_page to figure out what the current node is if the current page is displaying a node.

--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ