Contents |
For 0.7 we changed the "format" of portal-modules. You have no some more options, but also need to change everything, except the content of your output function.
From now on, the must-have file for a portalmodule is a file called yourmodule_name_portal.class.php (e.g. helloworld_portal.class.php). In this file you define the class "yourmodule_name_portal", which extends from portal_generic. So similar to this example:
class helloworld_portal extends portal_generic {
Afterwards you define the data of your portal-module in the following format:
protected $path = ''; protected $plugin = ''; protected $data = array( 'name' => '', 'version' => '0.0', 'author' => '', 'contact' => '', 'description' => '' ); protected $positions= array('left1', 'left2', 'right'); protected $settings = array(); protected $install = array( 'autoenable' => '0', 'defaultposition' => 'left1', 'defaultnumber' => '0', 'visibility' => '0', 'collapsable' => '1' ); protected $tables = array(); protected $sqls = array(); protected $position = '';
If your portal-module is not in a plugin, you dont need to define $plugin; just leave it away, similar for all otherthings you don't need. Important is, that $path is correctly set, it has to be the folder_name and your portal-modules-name (e.g. helloworld, but NOT helloworld_portal). $settings stayed the same compared to 0.6 module, just copy the old array. $install holds some defaults for first installation of your portal-module. If you need an extra sql-table, add the name of the table to the $tables array, and add the query to create the table to the $sqls array.
When you're done with that, you have to define the function "output".
public function output() { return 'Hello World'; }
You usually should be able to just copy&paste the old content of your output function.
If you want to change your module, regarding its position, you can easily do that, by getting the information about its current position from $this->position. Another new feature is the possibility of changing the header of your portal-module easily. Just implement the function "get_header", similar to here:
public function get_header() { return 'Hello '.$this->position.'!'; }
Name and Description of your module can be translated now. For our helloworld module, this language strings may be:
$lang['helloworld_name'] = 'Hallo Welt'; $lang['helloworld_desc'] = 'Dieses Modul soll dir zeigen, wie Portal-Module funktionieren.';
Use $user->lang($key), instead of $user->lang[$key]. For gettig your config, use $core->config($key);