Creating User modules for non-trixbox/freepbx applications

If you have installed packages outside of Trixbox and freepbx that you access by their folder (Example: http://server/folder), here is a simple process for adding these tools to the user login screen of Trixbox CE.

UPDATED: This example uses a little bit of javascript code to automatically match the page height so you will not need to have a scrollbar on the page.

(note: Some of the following code was pulled from the "Portal" module included with Trixbox CE)

1) Create a new folder in user/modules and give it a descriptive, url-friendly name.
2) Choose a module code to be used throughout the process. Can be anything, for instance I used "fop2" for creating a Flash Operator 2 module.
3) Create "module.xml file (replace everything in [] with your own values):

<opt>
	<module_folder>[folder you created]</module_folder>
	<tab_text>[module link text]</tab_text>
	<mouseover_title>[short module description]</mouseover_title>
	<tab_url>?[module code, note the preceding question mark!]</tab_url>
	<innerVar>[module code]</innerVar>
	<template>[module code].tpl</template>
	<config_file>configModule.php</config_file>
</opt>

4) Create configModule.php, you can adjust values to your liking:

<?php
$smarty->assign('pageWidth', '100%');
$smarty->assign("inner","[module code]");
?>

5) create template file "[module code].tpl (replace everything in [] with your own values):

{literal}
<script type="text/javascript">
function resizeFrame(f) {
var s;
s = 100;
f.style.height = s;
s = f.contentWindow.document.body.scrollHeight + "px";
f.style.height = s;
}
</script>
{/literal}

<div id="iframe">
	<iframe id="[module code]" name="[module code]" frameborder="0" border="0" width="100%"  src="[path to include]" onload="resizeFrame(document.getElementById('[module code]'))">
	</iframe>
</div>

Upload the folder and its contents to your webroot/user/modules directory and, the horizontal menu should now display your new module! When clicked, the page will contain an iframe with the module inside it.

If the page you are including needs to pass variables via $_GET, then you have to change some things in the .tpl file. For example, let's say we're making a module for a script that needs to pass the variable 'x':

{literal}
<script type="text/javascript">
function resizeFrame(f) {
var s;
s = 100;
f.style.height = s;
s = f.contentWindow.document.body.scrollHeight + "px";
f.style.height = s;
}
</script>
{/literal}

{php}
$x = $_GET['x'];
if(isset($x)){
    $src = '../manager/mymodule/page.php?x='.$x;
}else{
     $src = '../manager/mymodule/page.php';
}
{/php}

<div id="iframe">
	<iframe id="mymodule" name="mymodule" frameborder="0" border="0" width="100%"  src="{php}echo $src;{/php}" onload="resizeFrame(document.getElementById('mymodule'))"></iframe>
</div>