How do I use modSettings?

Started by TaskyZZ, December 16, 2007, 12:11:52 AM

Previous topic - Next topic


Can someone explain the usage of modSettings?  Or give a link to some documentation dealing with modSettings.

I first thought it was just a table in the database and I could add my settings and update it at will.  But, then I see from other posts here that it has something to do with settings being available in the admin control panel automatically or something like that?!?!

I put entries in the table and am able to retrieve them with $modSettings['mysetting'].  But, if I set the value to something else, it does not save.

I was going to just do an update on the table and update it myself, but that probably is not the correct way to go about it.  If someone could point me in the right direction, I would really appreciate it.

Thanks for any help!


modSettings is from the smf_settings table. It contains your forums settings. It shouldn't contain user settings at all. You can use it to add more settings for things you want to be able to change. It's purpose though I assume was for things like mods that need to add an option. But SMF uses it by default as well for option setups.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ ~ Support the SMF Support team!


It is available as $modSettings when writing a mod, but if I change a setting, it does not get saved to the database.  How do I save a setting?  Do I just update the table directly?

If I set my setting like this:

$modSettings['MyModName_setting'] = 1;

It does not get saved to the database.  How do I make the settings get saved?  Or should I just do an UPDATE query and save the setting myself?


You have to do a update query
Which will update the $modSettings['row_name'] variable.


Example of how to update from your example above

updateSettings(array('MyModName_setting' => '1'));
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more! -  Paid Modifications for SMF

EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro



Nevermind, I found the answer in another script.  The function I was looking for is "updateSettings()".

Imagine that...  the name even makes sense.   :P

Edit: Whoops, didn't realize others had posted the answer.  Thanks guys.  I appreciate it!!