MyBB Community Forums

Full Version: plugin setting dynamic field
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to generate plugin setting fields dynamically?

I am creating a plugin, which requires multiple values, that cannot be defined at the time of installation

Something like,

$mybb->settings['myplugin_dynamic1'];
$mybb->settings['myplugin_dynamic2'];
and so on...
What exactly are you trying to achieve? You can set new keys on the settings array, but they won't be saved to the database unless you actually insert them into the database.
i thin this may serve:

http://docs.mybb.com/1.8/development/plu...n-settings

Use the select box or radio or similar and add your values then set on your plugin args values and done, you may select that option and with a value you may change between one or two values, see yah !!
Say, I have 3 setting fields when my plugin installed, and option to add more fields
Active:Yes
Field1: value
Field2: value
-- Option to add additional field here --
Once I click on the link/button to add more fields, it should be created dynamically and should store its value to database.


Expected Result:
Active:Yes
Field1: value
Field2: value
Field3: value (dynamically created)
Field4: value (dynamically created)
-- Option to add additional field here --
create new sub page in acp like word filers
Look at MariaDB as a database instead of MySQL. You can get native support for something kind of like what you want. If you tweaked the database driver, you could dynamically add or remove fields on the fly.

https://mariadb.com/kb/en/mariadb/dynamic-columns/
(2015-04-15, 09:09 PM)Supryk Wrote: [ -> ]create new sub page in acp like word filers
You understood my requirement, however I could not figure out a way, how to do this?
Create a new .php file in admin/modules/config (or any other subfolder). It should be similar to other modules and include code like IN_MYBB check, $page->add_breadcrumb_item(), $page->output_footer(), your inputs, actions, etc. Then hook to submenu (located in admin/modules/[subfolder]/module_meta.php - for example admin_config_menu) and show a link to it. Similarly, implement admin permissions for it.
Really helpful, it worked! Thank you Smile