MyBB Community Forums

Full Version: Conditional ACP Settings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to hide certain settings until an option is checked?

For example, in the Board Closed setting window, when set to no there is no textarea for the reason but when set to yes the textarea is shown.

I want to provide an option that reveals other settings.

Any help would be appreciated.
when you create or modify an ACP page, you can use something like this:

$form_container->output_row($this->lang['setting_type'], $this->lang['setting_type_desc'], $form->generate_select_box('type', $posttypes, $this->settings['type'], array('id' => 'type')), 'type');

$form_container->output_row($this->lang['setting_type_photo_albums'], $album_desc, $form->generate_select_box('album_id', $albums, $this->settings['album_id'], array('id' => 'album_id')), 'album_id', array(),array('id' => 'row_album'));

and be sure to include this JS code as part of the page output:

'<script type="text/javascript" src="./jscripts/peeker.js"></script>
	<script type="text/javascript">Event.observe(window, "load", function() {var peeker = new Peeker($("type"), $("row_album"), /photo/, false);});
	</script>';

what it does is use the "type" labeled input to toggle the visibility of the "row_album" form object.
To be clear, is this code that can be used in the plugin install function?
no, it can not be used in the install function as settings in the config > settings page of the ACP. that piece uses a hardcoded peeker function without any hooks to add content.

what i posted only works when you create a new module page or a plugin that modifies an existing non-setting page (i.e. editing a group in the ACP)
Oh Sad

Then perhaps I should be more specific.

I would like to create a plugin and in the ACP settingsgroup for that plugin I would like 1 setting to show/hide other settings (settings that are unnecessary if the setting is off).

Sorry I wasn't more clear.
you can not do it. you can however, use a plugin to crate a new main tab/page or submenu item or add a setting to an existing page that can make use of the peeker functionality I posted.

here are a few examples of what i am talking about..

adding submenu items that can be used to open a new page with the settings you want
[attachment=28063]

modify an existing submenu's output and add a setting there
[attachment=28064]
Okay actually I don't even know how to add a page or tab, but I can think of a couple of plugins that do that so I can see how it is done.

How do I include the JS exactly? Sorry I am asking so many questions, but I really have a lot of holes in my knowledge.

Maybe I can just add the JS to the headerinclude template somehow?

Thanks for your help. I will be trying this stuff tonight Big Grin
when your plugin creates the ACP output, just slide the JS I posted into that output somewhere

if you grab MyBBPublisher v3.1 from my site, you can check the facebook module to see how I do it. its a bit different than normal though, since i store the output in a variable rather than dumping it directly like most pages. i have to do this due to how the publisher system is built, but you should be able to get the gist of it
I will definitely look into it.

Thanks for your help Smile +1
Just got it working. Thanks so much Smile