Passing Contemplate values into callback function
Balefire - June 26, 2008 - 13:46
| Project: | Magic Tabs |
| Version: | 5.x-1.1 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
This is my first Drupal site, and am still very much in the learning process. I would like to add a tabbed box to a contemplate page to help reduce the page length. I have things like:
<h3>Date of Appeal</h3><?php print $node->field_appeal_date[0]['view'] ?>
<h3>Appeal Details</h3><?php print $node->field_appeal_details[0]['view'] ?>etc, in the contemplate template. I would like to move those and several other fields into a tabbed box, but after several hours trying I am at a loss on how to have my magic_tabs_tml_callback() function in template.php add this information to $tabs['content']. I can modify the static text without issue. Could you provide an example of how to accomplish this? If Magic_Tabs is not set up to do this, could you suggest an alternate approach to achieve a similar result?
Thanks in advance.

#1
Run this code on the callback:
<?phpif (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
}
?>
And now you can use the $node object like you specified above.
#2
Thank you for that, I was soo close to that several times but couldn't get it to work properly. There was a small issue of it not giving me ['view'], and I tried node_view($node) which gave me a WSOD each time. With a bit of experimenting and reading, I found that node_build_content($node) gives me ['view']. Which I hope is correct.
I now have:
<?php
function magic_tabs_tml_callback() {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
node_build_content($node);
}
$tabs[] = array(
'title' => t('Incident Details'),
'content' => t('<h3>Date of Incident</h3>'.$node->field_incident_date[0]['view']),
);
...
?>
I realise there is probably more error checking, etc to do but at least the basics are working now! Cheers.
#3
Great!
Happy Drupaling :)