To build tabs, use the method «tabs» of the class «ui::».
There is also a special variant to create tabs inside a tab of the CRM account card with a fixed header using the helper «oj_to_card_tab()».
Example 1.
My Content for Tab 1
My Content for Tab 2
My Content for Tab 3
$tabs_pars = array();
$tabs_pars['children'] = array();
//--- TAB 1
$tab = array();
$tab['btn_text'] = 'My Tab 1';
$tab['body'] = e_p('My Content for Tab 1', 'mb-1');
$tabs_pars['children'][] = $tab;
//--- TAB 2
$tab = array();
$tab['btn_text'] = 'My Tab 2';
$tab['body'] = e_p('My Content for Tab 2', 'mb-1');
$tab['init_open'] = true;
$tabs_pars['children'][] = $tab;
//--- TAB 3
$tab = array();
$tab['btn_text'] = 'My Tab 3';
$tab['body'] = e_p('My Content for Tab 3', 'mb-1');
$tabs_pars['children'][] = $tab;
//===
$str .= ui::tabs($tabs_pars);Example 2.
Styling option, using the parameter «style_pills».
My Content for Tab 1
My Content for Tab 2
My Content for Tab 3
$tabs_pars = array();
$tabs_pars['children'] = array();
$tabs_pars['style_pills'] = true;
//--- TAB 1
$tab = array();
$tab['btn_text'] = 'My Tab 1';
$tab['body'] = e_p('My Content for Tab 1', 'mb-1');
$tabs_pars['children'][] = $tab;
//--- TAB 2
$tab = array();
$tab['btn_text'] = 'My Tab 2';
$tab['body'] = e_p('My Content for Tab 2', 'mb-1');
$tabs_pars['children'][] = $tab;
//--- TAB 3
$tab = array();
$tab['btn_text'] = 'My Tab 3';
$tab['body'] = e_p('My Content for Tab 3', 'mb-1');
$tabs_pars['children'][] = $tab;
//===
$str .= ui::tabs($tabs_pars);Example 3.
In this example, tab 2 is loaded via ajax, passing the handler identifier «my_example_3_tab_2» to the parameter «handler_tab». In the handler, we create content and return it using the helper «oj_tab()».
My Content for Tab 1
My Content for Tab 3
$tabs_pars = array();
$tabs_pars['children'] = array();
//--- TAB 1
$tab = array();
$tab['btn_text'] = 'My Tab 1';
$tab['body'] = e_p('My Content for Tab 1', 'mb-1');
$tabs_pars['children'][] = $tab;
//--- TAB 2
$tab = array();
$tab['btn_text'] = 'My Tab 2';
$tab['handler_tab'] = 'my_example_3_tab_2';
$tabs_pars['children'][] = $tab;
//--- TAB 3
$tab = array();
$tab['btn_text'] = 'My Tab 3';
$tab['body'] = e_p('My Content for Tab 3', 'mb-1');
$tabs_pars['children'][] = $tab;
//===
$str .= ui::tabs($tabs_pars);public function my_example_3_tab_2() {
$str = e_p('My Content for Tab 2 by ajax', 'mb-1');
$str .= e_p('DATETIME: '.e_datetime());
//===
oj_tab($str);
}Example 4.
In this example, tabs 1 and 3 are loaded via ajax. Also, the refresh button for tab 3 will be hidden.
My Content for Tab 2
$tabs_pars = array();
$tabs_pars['children'] = array();
$tabs_pars['style_pills'] = true;
//--- TAB 1
$tab = array();
$tab['btn_text'] = 'My Tab 1';
$tab['handler_tab'] = 'my_example_4_tab_1';
$tabs_pars['children'][] = $tab;
//--- TAB 2
$tab = array();
$tab['btn_text'] = 'My Tab 2';
$tab['body'] = e_p('My Content for Tab 2', 'mb-1');
$tabs_pars['children'][] = $tab;
//--- TAB 3
$tab = array();
$tab['btn_text'] = 'My Tab 3';
$tab['handler_tab'] = 'my_example_4_tab_3';
$tab['use_btn_reload'] = false;
$tabs_pars['children'][] = $tab;
//===
$str .= ui::tabs($tabs_pars);public function my_example_4_tab_1() {
$str = e_p('My Content for Tab 1 by ajax', 'mb-1');
$str .= e_p('DATETIME: '.e_datetime());
//===
oj_tab($str);
}
public function my_example_4_tab_3() {
$str = e_p('My Content for Tab 3 by ajax', 'mb-1');
$str .= e_p('DATETIME: '.e_datetime());
//===
oj_tab($str);
}The helper «oj_to_card_tab» is used to return content to a system tab inside a card in the EGO CRM account.
This is located here:
You can pass the same array of parameters to this helper as to the method «ui::tabs()». In this case, your tabs will be created inside the system tab, with the tab switch buttons fixed at the top, which is sometimes very convenient to work with.
