Starting from the top to the bottom, I'll explain how you can edit a module file.
You can use the portal/modules/portal_default.php as a base for your module.
First, edit the header to reflect your module name, i.e. this for the Gallery Block:
Code: Select all
/**
*
* @package Board3 Portal v2 - Gallery Block
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
Also make sure you change this line:
Code: Select all
/**
* @package Modulname
*/
Code: Select all
/**
* @package Gallery Block
*/
Now you have to modify the class name to reflect your module's name. If you filename is portal_gallery.php, you should name it portal_gallery_module:
Code: Select all
class portal_gallery_module
Code: Select all
/**
* Allowed columns: Just sum up your options (Exp: left + right = 10)
* top 1
* left 2
* center 4
* right 8
* bottom 16
*/
var $columns = 31;
Set the language variable of your module title. This language variable needs to be defined in the language file of your block.
Code: Select all
/**
* Default modulename
*/
var $name = 'PORTAL_GALLERY';
Code: Select all
/**
* Default module-image:
* file must be in "{T_THEME_PATH}/images/portal/"
*/
var $image_src = 'portal_gallery.png';
Code: Select all
/**
* module-language file
* file must be in "language/{$user->lang}/mods/portal/"
*/
var $language = 'portal_gallery_module';
If you want to use a custom acp template file, you can define it here:
Code: Select all
/**
* custom acp template
* file must be in "adm/style/portal/"
*/
var $custom_acp_tpl = '';
If your Block Title needs to change in the ACP or Portal depending on the settings in the ACP or you just don't want users to change the module title you can always force this by setting this switch to true:
Code: Select all
/**
* hide module name in ACP configuration page
*/
public $hide_name = false;
At the end of the function, you always return the template file that should be loaded:
Code: Select all
return 'modulename_center.html';
With function get_template_acp() you can define the ACP options:
Code: Select all
function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_BOTS_SETTINGS',
'vars' => array(
'legend1' => 'ACP_PORTAL_BOTS_SETTINGS',
'board3_last_visited_bots_number_' . $module_id => array('lang' => 'PORTAL_LAST_VISITED_BOTS_NUMBER' , 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);
}
If you have a config variable (i.e. $config['board3_last_visited_bots_number_' . $module_id'] where $module_id get's automatically assigned) defined by your module, you can just put it below 'legendx'. In the array, 'lang' stands for the language variable of this setting. If you set 'explain' to true, you also need to include the language variable + '_EXP' in you language variable. Again, just take a look at the portal files. With 'validate' you can define how the entered data should be treated. 'int' casts the input to int, while 'string' would cast it to a string. For a complete list of this, just take a look at the php documentation. 'type' defines what the setting should look like. 'text:3:3' would be a text box with the length of 3 and the maximum input length of 3.
The above code looks like this:
The function install always gets executed when you add the module. With this you can add i.e. your config variables. Make sure your config variables always start with a 'board3_' and that they are unique:
Code: Select all
function install($module_id)
{
set_config('board3_last_visited_bots_number_' . $module_id, 1);
return true;
}
Code: Select all
function uninstall($module_id)
{
global $db;
$del_config = array(
'board3_last_visited_bots_number_' . $module_id,
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE ' . $db->sql_in_set('config_name', $del_config);
return $db->sql_query($sql);
}