MyBB Community Forums

Full Version: How to do this with Plugin Library?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am doing a plugin for personal use and for avoid so many lines of code I'm using PluginLibrary, but I have some doubts when creating the settings ..

I have the following code, but it like I do with PluginLibrary?

global $db;
	
	$query = $db->simple_select("settinggroups", "COUNT(*) as rows");
	$rows = $db->fetch_field($query, "rows");
	
	$insertarray = array(
		'name' => 'pmpopup',
		'title' => 'PM Popup',
		'description' => 'Options on how to configure and personalize PM Popup',
		'disporder' => $rows+1,
		'isdefault' => 0
	);
	$gid = $db->insert_query("settinggroups", $insertarray);
	
	$insertarray = array(
		'name' => 'pmpopup_enable',
		'title' => 'Enable popup of private messages',
		'description' => 'Turns on or off PM Popup.',
		'optionscode' => 'onoff',
		'value' => 1,
		'disporder' => 0,
		'gid' => $gid
	);
	$db->insert_query("settings", $insertarray);

Search in the documentation, but it only found this but not know how change the values ​​there by of my code.

$PL->settings('plugin_name',
              'Group Title',
              'Group Description',
              array(
                  'no' => array(
                      'title' => 'Simple Yes/No Setting',
                      'description' => 'The default is no.',
                      ),
                  'yes' => array(
                      'title' => 'Simple Yes/No Setting',
                      'description' => 'This one is set to yes.',
                      'value' => 1,
                      ),
                  'text' => array(
                      'title' => 'Text setting',
                      'description' => 'Enter some text here.',
                      'optionscode' => 'text',
                      ),
                  'textarea' => array(
                      'title' => 'Text area setting',
                      'description' => 'Enter multiple lines of text.',
                      'optionscode' => 'textarea',
                      'value' => 'Default value for this setting.',
                      ),
                  )
    );

Know it is something basic, but do not understand XD
Thank you in advance :p
Something like this?

$PL->settings(
    'pmpopup', 
    'PM Popup', 
    'Options on how to configure and personalize PM Popup',
    array(
        'enable' => array(
            'title' => 'Enable popup of private messages',
            'description' => 'Turns on or off PM Popup.',
            'optionscode' => 'onoff',
            'value' => 1,
            ),
    )
);
If only it was a little lost.
But if I wanted to add a second adjustment of adjustments that group, as is?

Apologize for any inconvenience ..
Hä? I don't understand what you are asking, sorry. Can you rephrase?
I get it, it was just like adding another adjustment to that group, something.

$PL->settings(
    'pmpopup', 
    'PM Popup', 
    'Options on how to configure and personalize PM Popup',
		array(
			'enable' => array(
				'title' => 'Enable popup of private messages',
				'description' => 'Turns on or off PM Popup.',
				'optionscode' => 'onoff',
				'value' => 1,
            ),
			'enable2' => array(
				'title' => 'Example title',
				'description' => 'Example description',
				'optionscode' => 'onoff',
				'value' => 1,
            ),
		)
	); 

Is this right?

PS: To delete the setting group is only done with the name? well?

$PL->settings_delete('pmpopup');
Yes... $PL->settings() should be done in yourplugin_activate(), $PL->settings_delete() in yourplugin_uninstall(). That way people can deactivate your plugin without losing their settings, and $PL->settings() will update existing settings on activate.

You can see this in action in the hello_pl example plugin.
We got on and I also learned something management settings, thanks for the clarification Big Grin