By njguy on
How do you display a page variable like $tabs in your node template? I',m trying to do this for advanced placement options. I tried doing it like this
template.php
function theme_preprocess_page(&$vars) {
if ($vars['node']->type == "nodetype"){
$vars['template_files'][] = 'pagetemplate';
$vars['node_tabs'][] = $tabs;
}
}
node template
print $node_tabs;
Obviously this didn't work. What am I doing wrong?
Comments
Your are declaring
Your are declaring $vars['node_tabs'][] as an array. You can't print an array.
try doing this:
or you can scratch that if you change this:
I tried what you said before
I tried what you said before and again, no luck.
I've tried literally
I've tried literally everything i could think of, still nothing
I even tried this
variable $tabs isn't empty,
variable $tabs isn't empty, right?
for debugging, try this:
You should get a white empty screen with the array value of $tabs shown.
if $tabs is empty, you'll get "array()" displayed.
if you get nada, your theme doesn't look in this function (make sure you replace theme_ by your theme name in function name)
Use node rather than Page.
Hi all,
have you tried turning
function theme_preprocess_pageintofunction theme_preprocess_nodeI know you can override blocks and regions in these preprocess functions, currently trying to get $tabs into the node-tpl files as we have different UIs depending on node-type. Tricky stuff
Dom
Got it working
I managed to get the $tabs to the node.tpl.php like this:
First in the template.php add the following code
This will add the tabs to your $node variables. Then in node.tpl.php you can access the tabs like this:
Of course make sure to clear your cache after the changes :)