PDA

View Full Version : How do I load custome addon settings


jim6763nva
10-02-2007, 09:08 PM
Hi everyone,

This is again in regard to the World of Warcraft Lottery addon I'm working on. I have a custom settings page similar to other addon settings pages that gives the admin the ability to enable or disable the addon for maintenance purposes, as well as set other global addon settings. I've done some research on how to load setting values from the database by looking at other addon code and searched the forums here. I've seen it done several ways to sunday, but now I'm totally confused and frustrated.
Would anyone has some simple suggestions/example on how to do this?

Thank you in advance!
Jim

Analogpoint
10-03-2007, 12:29 AM
All settings are automatically loaded into the array $vbulletin->options by the vb core. Just use $vbulletin->options['your_setting_name'] to get the value.

Dismounted
10-03-2007, 05:29 AM
And in templates, you can use $vboptions.

jim6763nva
10-03-2007, 09:09 AM
I haven't put my settings in the vboptions though. I've created the following custom tables:
vb_lotteries
vb_lotterynumbers
vb_lotterysettings
vb_lotteryuserjoin


vb_lotterysettings fields
------------------------
name
value

this is so I can add more settings without altering the table structure.
Current settings include but are not limited to:

Name Value
HomeURL http://localhost/
lotteryactive 0
onoffreason "Lottery System is unavailable right now - please come back later"
Title "Test World of Warcraft Lottery System"

vb_lotteries fields
---------------------------
lotteryid
drawdate
ticketcost
jackpot

vb_lotterynumbers fields
---------------------------------
userid
ball1
ball2
ball3
ball4
ball5
ball6

vb_lotteryuserjoin fields
---------------------------------
userid
drawdate
confirm

Does this seem like the right way to go? Isn't there a more simple way of loading settings instead of using vboptions? This method seems a bit complex at my current stage of developing mods. :)

Thank you again for your input,
Jim

Analogpoint
10-03-2007, 01:15 PM
All those setting could go in vB's settings table and you'd save yourself a lot of trouble, and your pages won't have so many queries. For stuff like home url, don't create a new setting, use vB's 'bburl' setting.

jim6763nva
10-03-2007, 02:27 PM
Ok, I think I have the default settings worked out. Thank you all for your help! :)

In case you're interested in seeing what I have so far, I've included a screen shot:

Jim