Posted by yngens on May 28, 2008 at 12:04am
| Project: | Magic Tabs |
| Version: | 5.x-1.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Readme file says:
* You can theme individual tab group by writing your own _ function.
* You can override the generic theming function by implementing _magic_tabs.
Can you please provide any working example of this? Many non-coders would prefer to see copy-paste example in Readme to tweak and modify it little bit by themselves. Thanks!
Comments
#1
I added some more text about this in the README.
You can copy and paste theme_magic_tabs() from the module code and go from there.
#2
Automatically closed -- issue fixed for two weeks with no activity.
#3
Sorry to reopen this but I've been fighting with trying to custom theme a magic tabs block and have gotten nowhere.
Well, here's what I have in my template.php:
function latest_content_tabs($active = 0) {$bid = 205;
$block = (object)module_invoke('blockcache', 'block', 'view', $bid);
$block->module = 'blockcache';
$block->delta = $bid;
$tabs[] = array(
'title' => t('News'),
'content' => theme('magictabs', $block),
);
And where I'm stuck? The override function. Prior to the code above, in my template.php file, I have this code:
function theme_magictabs($callback, $items, $content) {return theme('block', $items, NULL, 'ul', array('class' => 'tabs')) .'<div class="magic_content">'. $content .'</div>';
}
I know I'm not making the call correctly, but I do know that at least it's seeing the override, as the blocks don't display properly. The thing is I have no idea how to properly call a block theme override (this example is taken from the module, but I haven't been able to find example code searching through Drupal.
According to the API, the theme block code looks like this:
function theme_block($block) {$output = "<div class=\"block block-$block->module\" id=\"block-$block->module-$block->delta\">\n";
$output .= " <h2 class=\"title\">$block->subject</h2>\n";
$output .= " <div class=\"content\">$block->content</div>\n";
$output .= "</div>\n";
return $output;
}
...but I can't see how I can implement this using the return theme line of code you proposed in your readme file.
My big concern is that I only want to display an ordered list of the block content, with absolutely nothing else (not even a block title -- no matter what I try it formats the block with a title, even if I have it set to in the block).
At this point, it is still attempting to display the block title, and even when it isn't present, it formats the area with css markup that messes up subsequent blocks below this.
Any help is appreciated. If I am better off posting this to the theme forum please let me know. Thanks!
BTW I've attached a screenshot showing what it looks like without my override function. The homepage setup is built using Panels2, and I have a custom block displayed called "Latest content". This block has one line of code,
<?php print magic_tabs_get('latest_content_tabs'); ?>. However, as you can see below the magic tabs, it is trying to display a formatted block title, even if there is none. So I'd like to override this to only print the list of links. You can also see how it messes up the block title below this one (called 'fanged films').