MyBB Community Forums

Full Version: How to add settings of a plugin?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to add settings of a plugin that shows up in ACP>> settings,
What is the function for it? and does we allow to use custom html /css in it for adding drop down lists, text fields, enable / disable options etc
I would recommend reverse engineering other plugins to learn how to do stuff Smile

E.G., Download http://mods.mybb.com/view/mytwitterwall and look at the source code to see how the settings in my plugin work Wink
The best way to learn is to read the code of other plugins. Here's the settings code from my Print Post plugin:

function printpost_activate()
{
    global $db, $lang;
    
    $settings = array(
        'enabled' => array(
            'title' => $db->escape_string($lang->printpost_enabled_title),
            'description' => $db->escape_string($lang->printpost_enabled_description),
            'optionscode' => 'yesno',
            'value' => true
        )
    );
    
    $settings_group = array(
        'gid' => null,
        'title' => 'Print Post Settings',
        'name' => 'printpost',
        'description' => $db->escape_string($lang->printpost_settings_description),
        'disporder' => 1,
        'isdefault' => 'no'
    );
    $db->insert_query('settinggroups',$settings_group);
    $gid = intval($db->insert_id());
    
    foreach( $settings as $name => $data )
    {
        static $i = 1;
        $data['name'] = 'printpost_'.$name;
        $data['sid'] = null;
        $data['disporder'] = $i;
        $data['gid'] = $gid;
        
        $db->insert_query('settings',$data);
        $i++;
    }
    
    rebuildsettings();
}

Settings are added through the $settings array and looped through into the database.
Thanks
Its better to use;
rebuild_settings();
instead;
rebuildsettings();

Both works though! Toungue
(2011-09-24, 11:35 AM)Yaldaram Wrote: [ -> ]Its better to use;
rebuild_settings();
instead;
rebuildsettings();

Both works though! Toungue

Thanks
(2011-09-24, 11:35 AM)Yaldaram Wrote: [ -> ]Its better to use;
rebuild_settings();
instead;
rebuildsettings();

Both works though! Toungue

/*
 * DEPRECATED! ONLY INCLUDED FOR COMPATIBILITY PURPOSES.
 */
function rebuildsettings()
{
	rebuild_settings();
}

Nice, I didn't know that. Thanks for the heads up!