I try to write a new application the first time and now I want share my knowledge, because I don't find something like that in the forum or somewhere else. I think when it's clear how to write a extension, more peple will do it and can extend the software faster. It will be nice, if you get suggestions for improvement!!!
New controller:
Create a new file called HelloworldController.class.php in the application/controllers folder. This controller will be loaded automatically and have one or more actions (here only one: index). You can set some variables to use they in the view template.
class HelloworldController extends ApplicationController {
function __construct() {
parent::__construct();
prepare_company_website_controller($this, 'website');
}
function index() {
$my_var = 'World';
tpl_assign('world', $my_var);
}
}
New view:
Create a file which is called equal to the action name, here index.php, in the application/views folder to show the output of the controller.
Hello <?php echo $world ?> !
Show the new application near the others as a tab:
Add it to the constructor of the TabPanel class to the items array in public/assets/javascript/og/layout.js :
var tab_panel = new Ext.TabPanel({
id: 'tabs-panel',
region:'center',
activeTab: 0,
enableTabScroll: true,
items: [
...
new og.ContentPanel({
title: lang('helloworld'),
id: 'helloworld-panel',
iconCls: 'ico-helloworld',
refreshOnWorkspaceChange: true,
defaultContent: {
type: "url",
data: og.getUrl('helloworld','index')
}
}),
Set a tab-label for the application:
For the English translation add a new item called helloword (see above) to the array in the javascript file language/en_us/lang.js.
...
'completed on': 'Completed on',
/* Hello World */
'helloworld': 'Hello World'
Now reload your opengoo and you will see your Hello World! application at the top.
Set an icon for the application:
The icon must set by the used theme, so for the default theme you save your icon by default in the public/assets/themes/default/images/16x16 folder.
Now connect the CSS class ico-helloworld to your image in the CSS file public/assets/themes/default/stylesheets/general/layout.css
.ico-helloworld {
background-image: url(../../images/16x16/helloworld.png) !important;
}