Utils/TabbedBrowser is a module that gives your module a tabbed interface — tabbed like tabs in a modern web browser.
To create an instance of the module, like any other module in Epesi:
$tabbed_browser = & $this->init_module('Utils/TabbedBrowser');
To display its content:
$this->display_module($tabbed_browser);
Inline tabs
Method syntax:
$tabbed_browser = & $this->init_module('Utils/TabbedBrowser');
$tabbed_browser->start_tab( <tab name> );
[tab's content]
$tabbed_browser->end_tab();
Example:
$tabbed_browser = & $this->init_module('Utils/TabbedBrowser');
$tabbed_browser->start_tab( 'Tab One' );
print 'Some data for tab one.';
$tabbed_browser->end_tab();
$tabbed_browser->start_tab( 'Tab Two' );
print 'Some data for tab two.';
$tabbed_browser->end_tab();
$tabbed_browser->start_tab( 'Tab Three' );
$i = 12;
print 'And a variable for tab three: ' . $i;
$tabbed_browser->end_tab();
This code displays three tabs. Each tab's content is whatever you print between its start_tab() and end_tab() calls.
Callback tabs
Method syntax:
$tabbed_browser = & $this->init_module('Utils/TabbedBrowser');
$tabbed_browser->set_tab( <tab name>, <callback function> );
Example:
$tabbed_browser = & $this->init_module('Utils/TabbedBrowser');
$tabbed_browser->set_tab( 'Tab One', array($this, 'function_1') );
$tabbed_browser->set_tab( 'Tab Two', array($this, 'function_2') );
$tabbed_browser->set_tab( 'Tab Three', array($this, 'function_3') );
$tabbed_browser belongs to.The code above creates three tabs ('Tab One' shown by default). Activating 'Tab One' prints whatever function_1 prints; 'Tab Two' and 'Tab Three' likewise show the output of function_2 and function_3 when activated.
More functionality
Utils/TabbedBrowser offers a few more methods worth knowing:
set_default_tab(<tab number>) — sets which tab is shown by default.switch_tab(<tab number>) — switches the displayed tab from within your PHP code.Note: when using
switch_tab(), remember to call$tabbed_browser->tag()inside each tab.