/[drupal]/contributions/modules/magic_tabs/README
ViewVC logotype

Contents of /contributions/modules/magic_tabs/README

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.2.4.2.1 - (show annotations) (download)
Fri Nov 7 06:34:51 2008 UTC (12 months, 2 weeks ago) by yhager
Branch: DRUPAL-6--1
Changes since 1.1.2.4: +18 -7 lines
added some clarifications about the callbacks usage
1 $Id: README,v 1.1.2.4 2008/07/29 05:39:52 yhager Exp $
2
3 = Installation =
4
5 * Unpack the project files onto your modules directory (usually
6 * 'sites/all/modules') Enable the module on the modules page
7 * ('http://example.com/?q=admin/build/modules')
8
9 = Overview =
10
11 This module requires coding capabilities, and does not expose any
12 UI. If you seek UI for creating the tabs, please take a look at
13 similar projects, like quicktabs.
14
15 = Usage =
16
17 The tabs are loaded from the server only when the user selects the tab
18 she wants to view. When the server is asked for the tabs content, it
19 calls a callback function that you supply. The callback fills in an
20 array of tabs with title and content. Make sure to place the callback
21 in a custom module, or in your theme's template.php file. The return
22 value of the callback should be an array of tabs, each tab is an array
23 with 'title' and 'content' keys. For example:
24
25 <?php
26 function magic_tabs_example_callback($active = 0) {
27 $tabs[] = array(
28 'title' => t('First magic tab'),
29 'content' => t('Content of first magic tab'),
30 );
31 $tabs[] = array(
32 'title' => t('Second magic tab'),
33 'content' => t('Content of second magic tab'),
34 );
35 $tabs[] = array(
36 'title' => t('Third and last magic tab'),
37 'content' => t('Content of third magic tab'),
38 );
39 return $tabs;
40 }
41 ?>
42
43 (such a function already exists in magic_tabs.module, you can use it for testing).
44
45 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 <?php
47 function magic_tabs_example_callback($active = 0) {
48 $tabs = array(
49 array('title' => t('First magic tab')),
50 array('title' => t('Second magic tab')),
51 array('title' => t('Third and last magic tab')),
52 );
53 $active = ($active + 3) % 3; // $active could be -1, which means last
54 $ordinals = array('first', 'second', 'third');
55 $tabs[$active]['content'] = 'This is the content of the '. $ordinals[$active] .' magic tab';
56 return $tabs;
57 }
58 ?>
59
60 When you want to present the magic tabs, all you have to do is:
61 <?php print magic_tabs_get('magic_tabs_example_callback'); ?>
62
63 You can display many tabs groups in a page.
64
65 == Displaying a custom block ==
66
67 The easiest way to display a custom block, is to find out the block id and add:
68 <?php
69 $bid = 2;
70 $block = (object)module_invoke('block', 'block', 'view', $bid);
71 $block->module = 'block';
72 $block->delta = $bid;
73 $tabs[] = array(
74 'title' => t('Display a custom block'),
75 'content' => theme('block', $block),
76 );
77 ?>
78
79 == Setting the default tab ==
80
81 By default, the contents of the first tab will be displayed.
82 You can have different tab displayed by using the second parameter to magic_tabs_get() call.
83
84 For example, to display the last tab:
85 <?php
86 print magic_tabs_get('mycallback', 'last');
87 ?>
88
89 You can use here 'first' (default), 'last' or a numeric value (first is 0).
90
91 = Theming =
92
93 * You can theme individual tab group by writing your own <yourtheme>_<yourcallback> function.
94 * You can override the generic theming function by implementing <yourtheme>_magic_tabs.
95
96 == Theming an indvidual tab group ==
97
98 Assuming your callback is called 'mycallback', it will be themed by calling
99 <?php theme('mycallback'); ?>, so you can override the theming using the
100 usual theme override mechanism in Drupal.
101 For more info about theming see http://drupal.org/node/55126
102
103 == Theming all magic tabs groups ==
104
105 Just override theme('magic_tabs') as mentioned above.
106 if you implement both specific and generic theming, the specific one is used first if it exists, otherwise, the generic one is used.
107
108 = Questions? Problems? =
109
110 Please use the issue queue from the project page at http://drupal.org/project/magic_tabs
111
112 = Notes =
113 * The original idea for the magic tabs was taken from http://drupal.org/nyobserver#comment-228682
114 * The CSS for the tabs was taken from http://exploding-boy.com/images/cssmenus/menus.html
115
116 Enjoy!

  ViewVC Help
Powered by ViewVC 1.1.2