WebMail Lite 7 documentation

Adding new tab to main menu

This example is about adding new screen, with the link added to main menu of the product. Primary data/plugins/custom-screen/index.php includes all the files:

<?php

class_exists('CApi') or die();

class CCustomPlugin extends AApiPlugin
{
	/**
	 * @param CApiPluginManager $oPluginManager
	 */
	public function __construct(CApiPluginManager $oPluginManager)
	{
		parent::__construct('1.0', $oPluginManager);
	}

	public function Init()
	{
		parent::Init();

		$this->AddJsFile('js/customScreen.js');
		$this->AddJsFile('js/include.js');
		
		$this->AddTemplate('CustomScreen', 'templates/customScreen.html');
	}
}

return new CCustomPlugin($this);

Plugin directory should contain 2 subdirectories called js and templates. They hold the following files:

data/plugins/custom-screen/js/customScreen.js file:

/**
 * @constructor
 */
function CCustomScreen()
{
	
}

data/plugins/custom-screen/js/include.js file:

function initialize()
{
	var
		sName = 'custom',
		sHeaderTitle = 'Custom',
		sDocumentTitle = 'Custom',
		sTemplateName = 'Plugin_CustomScreen',
		oViewModelClass = CCustomScreen
	;
	
	window.AfterLogicApi.addScreenToHeader(sName, sHeaderTitle, sDocumentTitle, sTemplateName, oViewModelClass);
}

initialize();

data/plugins/custom-screen/templates/customScreen.html file:

<h1>This is custom screen!</h1>

While include.js file determines texts displayed in WebMail interface, customScreen.html should hold the actual screen to be displayed. For example, you can have IFrame there containing the output you require.

To enable the plugin, add the following item to data/settings/config.php file:

'plugins.custom-screen' => true,