4 * Unpack the project files onto your modules directory (usually
5 * 'sites/all/modules') Enable the module on the modules page
6 * ('http://example.com/?q=admin/build/modules')
10 This module requires coding capabilities, and does not expose any
11 UI. If you seek UI for creating the tabs, please take a look at
12 similar projects, like quicktabs.
16 The tabs are loaded from the server only when the user selects the tab
17 she wants to view. When the server is asked for the tabs content, it
18 calls a callback function that you supply. The callback fills in an
19 array of tabs with title and content. Make sure to place the callback
20 in a custom module, or in your theme's template.php file. The return
21 value of the callback should be an array of tabs, each tab is an array
22 with 'title' and 'content' keys. For example:
25 function magic_tabs_example_callback($active = 0) {
27 'title' => t('First magic tab'),
28 'content' => t('Content of first magic tab'),
31 'title' => t('Second magic tab'),
32 'content' => t('Content of second magic tab'),
35 'title' => t('Third and last magic tab'),
36 'content' => t('Content of third magic tab'),
42 (such a function already exists in magic_tabs.module, you can use it for testing).
44 Note that only the tab with the active content will be visible, so if you don't have to render the content of the other tabs (save processing). For example, you could have written the above function like this:
46 function magic_tabs_example_callback($active = 0) {
48 array('title' => t('First magic tab')),
49 array('title' => t('Second magic tab')),
50 array('title' => t('Third and last magic tab')),
52 $active = ($active + 3) % 3; // $active could be -1, which means last
53 $ordinals = array('first', 'second', 'third');
54 $tabs[$active]['content'] = 'This is the content of the '. $ordinals[$active] .' magic tab';
59 When you want to present the magic tabs, all you have to do is:
60 <?php print magic_tabs_get('magic_tabs_example_callback'); ?>
62 You can display many tabs groups in a page.
64 == Displaying a custom block ==
66 The easiest way to display a custom block, is to find out the block id and add:
69 $block = (object)module_invoke('block', 'block', 'view', $bid);
70 $block->module = 'block';
73 'title' => t('Display a custom block'),
74 'content' => theme('block', $block),
78 == Setting the default tab ==
80 By default, the contents of the first tab will be displayed.
81 You can have different tab displayed by using the second parameter to magic_tabs_get() call.
83 For example, to display the last tab:
85 print magic_tabs_get('mycallback', 'last');
88 You can use here 'first' (default), 'last' or a numeric value (first is 0).
92 * You can theme individual tab group by writing your own <yourtheme>_<yourcallback> function.
93 * You can override the generic theming function by implementing <yourtheme>_magic_tabs.
95 == Theming an indvidual tab group ==
97 Assuming your callback is called 'mycallback', it will be themed by calling
98 <?php theme('mycallback'); ?>, so you can override the theming using the
99 usual theme override mechanism in Drupal.
100 For more info about theming see http://drupal.org/node/55126
102 == Theming all magic tabs groups ==
104 Just override theme('magic_tabs') as mentioned above.
105 if you implement both specific and generic theming, the specific one is used first if it exists, otherwise, the generic one is used.
107 = Questions? Problems? =
109 Please use the issue queue from the project page at http://drupal.org/project/magic_tabs
112 * The original idea for the magic tabs was taken from http://drupal.org/nyobserver#comment-228682
113 * The CSS for the tabs was taken from http://exploding-boy.com/images/cssmenus/menus.html