MyBB Community Forums

Full Version: Adding settings to existing settinggroups.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Often plugins add an entire new setting group when they have just a couple settings. Ones that might fit nicely with the existing groups. The problem is that people use the gid column which can be inaccurate as upgraded forums might have different than the default system.

Here is the few lines I use to determine the actual gid and I encourage other authors to use this method.

Quote: $query = $db->simple_select("settinggroups", "gid", "name='member'");
$gid = intval($db->fetch_field($query, "gid"));

In this case I am trying to get the "member" settings gid.

Here is the list of default names used for settings.

banning
onlineoffline
calendar
clickablecode
cpprefs
datetime
forumdisplay
forumhome
general
memberlist
portal
posting
reputation
privatemessaging
server
showteam
showthread
member
whosonline
search
mailsettings
warning

Now adding a setting to one of these existing groups is easy.

Quote: $setting_1 = array(
"name" => "NAME",
"title" => "TITLE",
"description" => "YOUR_DESCRIPTION",
"optionscode" => "OPTION_TYPE",
"value" => "VALUE",
"disporder" => "20",
"gid" => $gid,
);
$db->insert_query("settings", $setting_1);

Replace all red text with your own info.

I also suggest that for display order you have it after all the regular settings ...probably start it at around 20 or even 30 depending on the group. IMHO it's sloppy if a new setting that's custom is on top of the other settings. Personal pet peeve.

Plugin authors should know how to use this code.

Enjoy.
(2009-08-30, 09:25 PM)labrocca Wrote: [ -> ]Often plugins add an entire new setting group when they have just a couple settings.

I would create a custom setting group for a plugin even if the plugin added just one single setting. That's what custom setting groups are there for. With your own group, your plugins settings are easier to find, and prevents them being confused with official settings.
Sure I know it's preference but like I said...personal pet peeve. Also it adds one useless row to the settingsgroups table. Maybe that's what bothers me.
You could add a million rows to the settinggroups table without hurting your forum any. The table isn't used anywhere except on the Admin CP configuration page, so technically there's no downside to creating additional groups whatsoever. In the end, sure, it's personal preference and it's the choice of the plugin author.
I also rather have a separate settings row rather than messing with the default settings groups. Best to keep the default and the custom plugin settings separate.

As for the inconsistency in the gids across upgraded forums, doesn't mybb recommend deactivating/uninstalling plugins before doing an upgrade? That I think should take care of that problem as when the plugin is reactivated it will use the new gids if they have changed.

With all that said, one thing that bothers me is when a plugin doesn't set the display order properly and hence it shows up way at the top on the settings page. One of those personal pet peeves for me I guess Wink