Print information associated with a node elsewhere in page.tpl.php, using a separate template file for theming
Thanks to a little refresher on the _phptemplate_callback function (replaced in Drupal 6's theming system with the theme registry) from searching Nick Lewis' site.
<?php
function _phptemplate_variables($hook, $vars = array()) {
if ($hook == 'page') {
if ($vars['node'] && arg(2) != 'edit') {
$vars['brandbar'] = _phptemplate_callback('brandbar', array('node' => $vars['node']));
}
// ...
}
?>
That didn't give us the variables with the same values, in the same formats, we were used to getting them in the node.tpl.php, however. So we called on the patented (no, not really) Agaric way of loading nodes for a template file the same way they get presented to node.tpl.
This is the result (also we added filtering by node type to the if statement), not including the full agaric_node_load_view function which of course also must be in template.php or otherwise available:
<?php
function _phptemplate_variables($hook, $vars = array()) {
if ($hook == 'page') {
if ($vars['node'] && arg(2) != 'edit' && $vars['node']->type == 'partner') {
$vars['brandbar'] = _phptemplate_callback('brandbar', array('node' => agaric_node_load_view($vars['node']->nid)));
}
// ...
?>
This seems quite an inefficient way to do this though. Probably we could call on CCK to render values per-field? It would be nice, also, if Drupal were caching the view node information, and if it were accessible without our using this whole retreaded function.
Comments
Post new comment