This page is under construction.

Each plugin support a database, for example to save a text. I will explain how to make a simple plugin with two text fields.

If you never made ​​a plugin I recommend reading the following article Creating a simple Hello World plugin.

Step 1: Create the file system structure for the plugin, inside the plugins folder. This plugin will be called About Me and the folder will be called about_me (folder name must not contain spaces).

-- about_me
    |-- languages
    |   |-- en_US.bit
    `-- plugin.bit

Note: this file system structure is mandatory.

Step 2: Edit the plugin.bit file and write the class for the new plugin.

<?php

$_PLUGIN_CONFIG['DATA'] = array(
	'author'=>'My name or nickname',
	'version'=>'1.0',
	'url'=>'http://www.mysite.com'
);

class PLUGIN_ABOUT_ME extends Plugin
{
	
}

?>

Step 3: Define the method __construct() with the fields for database. For example full_name and age fields. You can pre defined the value of each field.

<?php

$_PLUGIN_CONFIG['DATA'] = array(
	'author'=>'My name or nickname',
	'version'=>'1.0',
	'url'=>'http://www.mysite.com'
);

class PLUGIN_ABOUT_ME extends Plugin
{
	function __construct()
	{
		parent::__construct();

		$this->fields = array('name'=>'', 'age'=>28);
	}
}

?>

Step 4: Define the method dashboard_config(), this method will be called / printed when you configure the plugin from the dashboard.

class PLUGIN_ABOUT_ME extends Plugin
{
	function __construct()
	{
		parent::__construct();

		$this->fields = array('full_name'=>'', 'age'=>28);
	}

	public function dashboard_config()
	{
		// Get from database the name and the age
		$full_name = $this->database('full_name');
		$age = $this->database('age');
		
		$html  = '<label>Name</label>';
		$html .= '<input name="full_name" type="text" value="'.$full_name.'">';

		$html .= '<label>Age</label>';
		$html .= '<input name="age" type="text" value="'.$age.'">';

		return $html;
	}
}

?>

As you can see, to get the value from the database you can call the method database(FIELD_NAME), for example to recovery the full name field: $this->database('full_name') or to get the age from database: $this->database('age').

Now to modify and save the new value, you need to create some inputs text, each input will be named like the field from database.

For example for the field full_name.

<input name="full_name" type="text" value="">

Step 5: Method blog_body(), this will be called / printed at the blog.

<?php

$_PLUGIN_CONFIG['DATA'] = array(
	'author'=>'My name or nickname',
	'version'=>'1.0',
	'url'=>'http://www.mysite.com'
);

class PLUGIN_ABOUT_ME extends Plugin
{
	function __construct()
	{
		parent::__construct();

		$this->fields = array('full_name'=>'', 'age'=>28);
	}

	public function dashboard_config()
	{
		// Get from database the name and the age
		$full_name = $this->database('full_name');
		$age = $this->database('age');
		
		$html  = '<label>Name</label>';
		$html .= '<input name="full_name" type="text" value="'.$full_name.'">';

		$html .= '<label>Age</label>';
		$html .= '<input name="age" type="text" value="'.$age.'">';

		return $html;
	}

	public function blog_body()
	{
		// Get from database the name and the age
		$full_name = $this->database('full_name');
		$age = $this->database('age');

		$html = '<p>Hello my name is '.$full_name.' and I am '.$age.' years old</p>';

		return $html;
	}
}

?>

Step 6: Edit the language (en_US.bit) file with some information about the plugin.

<?php

$_PLUGIN_CONFIG['LANG'] = array(
	'NAME'=>'About me',
	'DESCRIPTION'=>'My name and my age',
);

?>