Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
tabtree Class Reference

Stores tabs list. More...

Inheritance diagram for tabtree:
tabobject renderable templatable

Public Member Functions

 __construct ($tabs, $selected=null, $inactive=null)
 Constuctor.
 
 export_for_template (renderer_base $output)
 Export for template.
 
 find ($id)
 Travels through tree and finds a tab with specified id.
 

Public Attributes

bool $activated = false
 indicates that this tab's child is selected
 
string $id
 unique id of the tab in this tree, it is used to find selected and/or inactive tabs
 
bool $inactive = false
 whether the tab is inactive
 
int $level = 1
 level of tab in the tree, 0 for root (instance of tabtree), 1 for the first row of tabs
 
moodle_url string $link
 link
 
bool $linkedwhenselected = false
 whether to display a link under the tab name when it's selected
 
bool $selected = false
 indicates that this tab is selected
 
array $subtree = array()
 stores children tabobjects
 
string $text
 text on the tab
 
string $title
 title under the link, by defaul equals to text
 

Protected Member Functions

 set_level ($level)
 Allows to mark each tab's level in the tree before rendering.
 
 set_selected ($selected)
 Travels through tree and finds the tab to mark as selected, all parents are automatically marked as activated.
 

Detailed Description

Stores tabs list.

Example how to print a single line tabs: $rows = array( new tabobject(...), new tabobject(...) ); echo $OUTPUT->tabtree($rows, $selectedid);

Multiple row tabs may not look good on some devices but if you want to use them you can specify ->subtree for the active tabobject.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.5

Constructor & Destructor Documentation

◆ __construct()

tabtree::__construct ( $tabs,
$selected = null,
$inactive = null )

Constuctor.

It is highly recommended to call constructor when list of tabs is already populated, this way you ensure that selected and inactive tabs are located and attribute level is set correctly.

Parameters
array$tabsarray of tabs, each of them may have it's own ->subtree
string | null$selectedwhich tab to mark as selected, all parent tabs will automatically be marked as activated
array | string | null$inactivelist of ids of inactive tabs, regardless of their level. Note that you can as weel specify tabobject\$inactive for separate instances

Member Function Documentation

◆ export_for_template()

tabtree::export_for_template ( renderer_base $output)

Export for template.

Parameters
renderer_base$outputRenderer.
Return values
object

Reimplemented from tabobject.

◆ find()

tabobject::find ( $id)
inherited

Travels through tree and finds a tab with specified id.

Parameters
string$id
Return values
tabtree|null

◆ set_level()

tabobject::set_level ( $level)
protectedinherited

Allows to mark each tab's level in the tree before rendering.

Parameters
int$level

◆ set_selected()

tabobject::set_selected ( $selected)
protectedinherited

Travels through tree and finds the tab to mark as selected, all parents are automatically marked as activated.

Parameters
string$selectedthe id of the selected tab (whatever row it's on), if null marks all tabs as unselected
Return values
boolwhether this tab is selected or contains selected tab in its subtree

The documentation for this class was generated from the following file: