Project

General

Profile

Actions

Tabs

Tabs are used to divide the page into multiple sections. Each of these sections can define its own content. Tabs look like this in chamilo:

Tabs can be created in three different ways. Dynamically, statically or in forms.

Dynamic Tabs

When creating dynamic tabs, the content is already created and rendered in html when the page is loaded. The tabs work with the use of javascript to select another tab and view other content.

To create the tabs you need to create a new DynamicTabsRenderer.

$tabs = new DynamicTabsRenderer($name);

You can add two kind of tabs to the dynamic tabs renderer. Either you create a dynamic tab with html content or you create an action tab in which several actions are defined.

Dynamic Content Tab

In the dynamic content tab you can add html content to your dynamic tab.
You need to create a new DynamicContentTab and add it to the tabs renderer.

$tab = new DynamicContentTab($id, $name, $image, $content);
$tabs->add_tab($tab);

Dynamic Action Tab

In the dynamic action tab you can add several actions, links to other pages.
First you need to create a new DynamicActionsTab and add it to the tabs renderer

$tab = new DynamicActionsTab($id, $name, $image, $actions = array());
$tabs->add_tab($tab);

Then you need to create a new DynamicAction and add it to the tab.

$action = new DynamicAction($title, $description, $image, $url, $confirm = false);
$tab->add_action($action);

Render

To render the tabs you need to call the method render from the tabs renderer.

echo $tabs->render();

Form Tabs

Form tabs work the same way as dynamic tabs but are built to display a form over several tabs.
To create the tabs on your form you need to create a new DynamicFormTabsRenderer.

$tabs = new DynamicFormTabsRenderer($name, $form);

When the tabs renderer is created you will need to add tabs to the tabs renderer. To add a tab to the tabs renderer you need to create a new DynamicFormTab.

$tab = new DynamicFormTab($id, $name, $image, $method);
$tabs->add_tab($tab);

The method parameter is the name of the method which must be called in the active form. (The same form that was a parameter of the DynamicFormTabsRenderer)

To render the tabs you need to call the method render from the tabs renderer.

echo $tabs->render();

Static Tabs

When creating static tabs, the content of the active tab is loaded. Switching to a different tab means that the page needs to be reloaded to retrieve the content of the active tab.

To create the tabs you need to create a new DynamicVisualTabsRenderer.

$tabs = new DynamicVisualTabsRenderer($name, $content);

The content parameter will be the (html) content of the active tab.

When the tabs renderer is created you will need to add tabs to the tabs renderer. To add a tab to the tabs renderer you need to create a new DynamicVisualTab.

$tab = new DynamicVisualTab($id, $name, $image, $link, $selected = false);
$tabs->add_tab($tab);

To render the tabs you need to call the method render from the tabs renderer.

echo $tabs->render();

If you can not add the contents at the constructor time you can use the set_content function afterwards

$tabs->set_content($content);

Updated by Sven Vanpoucke over 11 years ago ยท 5 revisions