Latest News:
Latest Mods: Latest Tutorials:


 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin settings?
Author Message
Lee Merriman
Junior Member


Posts: 3
Joined: Apr 2011
Reputation: 0
Post: #1
Plugin settings?
I've made a few (Read, 2) MyBB plugins before, but I've never figured out how to add settings. Is there a resource on this somewhere?
04-21-2011, 08:48 AM


euantor
Posting Freak



Posts: 868
Joined: Jun 2009
Reputation: 6
Post: #2
RE: Plugin settings?
That's actually quite simple. Take a look at the below snippet from one of my plugins:

PHP Code:
function myvids_activate() {
    global 
$db$mybb$lang;
    
    
$settings_group = array(
        
"gid" => "",
        
"name" => "myvids",
        
"title" => "MyVids",
        
"description" => "Setting group for the MyVids plugin.",
        
"disporder" => "0",
        
"isdefault" => "0",
    );
    
    
$db->insert_query("settinggroups"$settings_group);
    
$gid $db->insert_id();
    
    
$setting[1] = array(
        
"name" => "myvidson",
        
"title" => "Enable MyVids?",
        
"description" => "Set this to yes to turn on the MyVids system.",
        
"optionscode" => "yesno",
        
"value" => "1",
        
"disporder" => "1",
        
"gid" => $gid,
    );
    
    
$setting[2] = array(
        
"name" => "myvidseo",
        
"title" => "Enable MyVids SEO URLs?",
        
"description" => "Do you wish to use \"SEO Firendly\" URLs in the video system? To use SEO Friendly URLs, you must make the edits to your .htacces file as outlined in the plugin documentation.",
        
"optionscode" => "yesno",
        
"value" => "0",
        
"disporder" => "2",
        
"gid" => $gid,
    );
    
    foreach (
$setting as $row) {
        
$db->insert_query("settings"$row);
    }
    
rebuild_settings();


Hope that helps you understand. others may do it slightly differently,but that's the basics.
04-21-2011, 12:57 PM
 




User(s) browsing this thread: 2 Guest(s)