PDA


View Full Version : Creating a module that gets variable from the admincp


jonnyquest
02-04-2006, 08:47 PM
Hi,

I need to create a module that will be used on a lot of different pages. On each of these pages, I want to be able to customize certain variables in this module. Rather than bury my variables in php code, I'd prefer to input these variables from the admincp as is done with the modules that ship with vBa. I've looked into the code and db structure and it appears that there are a set of default settings and than each page customizes these variables using some code that looks like: :{s:7:"varname";s:17:"portal_rss_iconid";s:10:"grouptitle";s:19:"adv_portal_rss_feed";s:5:"value";s:0:"";s:12:"defaultvalue";s:0:"";s:10:"optioncode";s:0:"";s:12:"displayorder";s:1:"7";s:5:"title";s:14:"Icon ID to use";s:11:"description";s:57:"Specify an optional Thread Icon ID to affix to the title.";}s:20:"portal_rss_cachepath";a:8:{

An example for clarification: I want to build a Moderators module. I want to put this on 6 different vBa pages. On each page, I want to pull the moderators from a specific forum. I'd like to be able to go into the Edit Page section and look for the Moderators module section where there is an input box for 'Forumid's to pull moderators from'. By changing this for each page, it would change the SQL that the php is using to pull the mods.

Nowhere on this site have I been able to find discussion about how to go about setting up the db and php so I can do this.

Any help:

Tom M
02-04-2006, 09:15 PM
You need to put the ACP into debug mode. This will give your the ability to add/modify variables within the ACP structure including within CMPS. To place the ACP in debug mode add the following to the includes/config.php file;

$config['Misc']['debug'] = true;

It's a good idea not to do this on your live board as I believe that some extra information is available to non-admin users as well.

jonnyquest
02-05-2006, 02:54 AM
Wow, this looks very straight-forward. Are there any docs for adding a setting? If not, maybe a few basic questions. Most of the fields look straight forward. I assume that you simply name the variable and than you can access that variable from within the module php script.

The only one I'm a bit unsure of is the Option Code. I looked at some and they are select tags with settings that are variables. Others are just a variable name. Is this box referred to in the php code?

Finally, I'm looking to make some fairly straight-forward modules that pull out a featured posts or pull top posters. The functionality of these scripts isn't far from something such as the News module, however, the news module looks fairly complex to try and take apart and put back together. Is it really fairly straight-forward or am I better just writing some basic php code myself and starting a module from scratch?

Thanks!

Brian
02-06-2006, 04:51 PM
The Option Code setting controls what type of setting you will see.

textarea = A textarea
yesno = Radio buttons with Yes/No as choices
forumselect = A multiple select box that will return a list of your forums.
calendarselect = A select box that will return a list of your calendars
threadselect = The 'Edit Threads' link that you will see with the news or recent threads modules
"blank" = A normal text input field.

The news module may be a little complex since it handles the news archive and quite a few things with the news posts. You may want to have a look at some of the other modules such as latesttopics.php and stats.php if you want something easier to pick apart.