Support Forum
Hi
I've been working on integrating MetaBox into a plugin and it has worked well so far. Essentially I have been building a backend administration console that I can hand over to end users of the site which means, depending on the type of site that it is, some of the options I'm building into it won't really be applicable.
The plugin makes extensive use of Settings page, groups and tabs. I had wondering if there is any way that it would be possible to have a 'master' tab that controlled the visibility of other tabs in the settings page but after consulting the documentation and reading through this forum extensively it looks as if this is not currently possible.
Can you suggest any way that it might be possible to do this? I've considered the possibility of a second settings page, installed prior to the main one that would allow the selection of the various options to appear in the main settings page and then build up the settings page from the values that get stored in this other settings page (possibly utilising an external xml file.
Another related question which isn't mentioned in any of the documentation that I've read on using composer to incorporate MetaBox into a plugin. When you yourselves upgrade MetaBox I will obviously need to upgrade my own plugin. Is it simply sufficient to rom 'conposer update'?
Many thanks.
I had similar settings trouble. I resolved with putting into every tab one switch element and when swith element is on i show a group of fields.
Another possible solution would be (i haven't tried).
Into first tab add swithes elements one for every tab.
Then add a field of actived tabs only if switch in on.
$main_config = [
'title' => __( 'Main Page', 'igm-reviews' ),
'id' => 'main-page',
'tab_style' => 'box',
'tab_default_active' => 'tab_main',
'tabs' => [
'tab_main' => [
'label' => 'Activate TABS',
'icon' => 'admin-home',
],
'tab_1' => [
'label' => 'TAB 1',
'icon' => '',
],
'tab_2' => [
'label' => 'TAB 2',
'icon' => '',
]
],
'fields' => [
[
'tab' => 'tab_main',
'name' => __( 'Activate Tab 1?', 'textdomain' ),
'id' => 'tab_1',
'type' => 'post',
'field_type' => 'switch',
],
[
'tab' => 'tab_main',
'name' => __( 'Activate Tab 2?', 'textdomain' ),
'id' => 'tab_2',
'type' => 'post',
'field_type' => 'switch',
],
];]
// Then after saving tabs you check if switch are activated and add configuration array to main array
$tab_1 = [
'tab' => 'tab_1',
'name' => __( 'Input Title', 'textdomain' ),
'id' => 'title,
'type' => 'post',
'field_type' => 'text',
],
$tab_2 = [
'tab' => 'tab_2',
'name' => __( 'Input Name', 'textdomain' ),
'id' => 'name,
'type' => 'post',
'field_type' => 'text',
],
if( switch(tab_1) == on )
//then add to main array
$main_array['fields][] = $tab_1
return $main_array
Code isen't tested. only for example.
see pastbin https://pastebin.com/CGd7p9LH
Thanks Max, I'll have a play with that and see how I get along.