IFrame application
Navigate CMS allows embedding external web applications via IFrame. This mechanism is useful for extended website statistics, webmail interfaces, utilities, etc. One good example of this feature is the phpMyAdmin extension.
Due to the great customization features of phpMyAdmin, the extension interface is very integrated in Navigate CMS (both projects use the same set of icons!). Let's start explaining how it works with the extension definition:
{
"title": "phpMyAdmin",
"version": "1.0",
"author": "Naviwebs",
"website": "http://www.phpmyadmin.net",
"description": "Runs phpMyAdmin in an IFrame to access the configured database.",
"type": "admin",
"run": true,
"languages":
{
"en": "i18n/en.json"
}
}
The key here is the "run": true property, it makes the extension executable by double clicking its thumbnail in the extensions function.
The IFrame extensions do not require the main PHP file "extension_name.php" but they do require a file named "run.php" with, at least, an existing function named "extensionname_run":
<?php
function phpmyadmin_run()
{
global $layout;
$content = "";
$content.= '<iframe id="navigate-content-iframe"
src="about:blank"
border="0"
frameborder="0"
allowtransparency="true"
height="100%"
width="100%">
</iframe>';
$layout->add_script('
$(window).load(function()
{
$("#navigate-content").css({"padding": "0px"});
$("#navigate-content-iframe").attr(
"src",
"'.NAVIGATE_URL.'/plugins/phpmyadmin/load.php"
);
$(window).trigger("resize");
});
');
return $content;
}
?>
So, your function creates some HTML/JS code and Navigate CMS will display it in the main content zone of the application. In fact, your function is responsible to create the IFrame or any other component you may need (someone said a flash app? ;). With this method, you can even create your own Navigate CMS compatible functions.
In the example, $content contains the HTML code (which is returned to Navigate CMS) and the Javascript code is added to the $layout object, which generates the whole page code. If you need more information on this subject you'll have to check the Developer's manual and learn how to work with the layout, navibars, naviforms objects...
This extension is particularly powerful because it downloads the full phpMyAdmin project package, decompresses and creates the configuration file. With zero configuration and a few seconds, an Administrator can have a fully functional database access. Check the full source code if you want to know how all this process is done.
0 Comments