Joomla xAJAX Plugin Mambot For Components and Modules

About This Project
This project exposes the xAJAX framework functionality to Joomla Components, extensions and plugins by setting up the xAJAX system and allowing it to be extended by one or more Joomla Plugins/Extensions. 
 
This allows 3rd party developers the ability to write stunning applications that incorporate the xAJAX functionality without having to distribute xAJAX along with their components and also prevents conflicts between multiple xAJAX applications.
 
Our first version is NOW AVAILABLE FOR DOWNLOAD!
Tags: 3, developer, information, joomla, xajax,
Click to add your tags...,
 
The Problem
The problem this plugin solves is simple. With the current framework for Joomla 1.0.10 and the current version of xAJAX, only one xAJAX component can run at a time.  If you try to run more than one component that uses xAJAX at a time one will work and the others will not.  This is because the Javascript that powers xAJAX is added to the head of the HTML and doing this more than once will result in duplicate function calls and overridden variables.
 
For example.  If you install a commenting component that uses xAJAX in a mambot and a knowledgebase component that also needs xAJAX they both try to add code to the HTML Head tag that powers these features.  One will knock out the other causing sites to not function correctly.
 
Tags: 3, joomla, mambot, solution, xajax,
Click to add your tags...,
 
The Solution
The xAJAX Plugin for Joomla is a mambot/plugin that contains the very latest version of xAJAX. the Mambot/Plugin is fired on the onAfterStart trigger and sets up the xAJAX object alowing 3rd party developers to extend the functionality. It works like this: 
  • When the plugin is triggered it starts a new xAJAX instance
  • This instance is configured by the params of the plugin set in admin (Debug etc.)
  • The plugin will then search all components folders for an extenstion to xajax: Eg:
    For components:  /components/com_example/xajax.example.php
    For Modules and Plugins:   NO SOLUTION YET!
  • If the xajax extension file is found it is included and its methods added to the xAJAX object
  • Once all the files and methods are included the plugin adds the xAJAX Javascript to the HEAD tag of the HTML
This then allows multiple components to register their PHP Function names in the xAJAX object before the JS is written out.
 
When a JS action is called (E.g. xajax_example() ) the same process is followed and the relavant PHP Function in the relavant file is called. The component can then act on the input and return the normal xAJAX response.
 
 
Tags: d, solution,
Click to add your tags...,
 
How to use (For Developers)
Using the xAJAX Plugin extension in your components is even simpler than integrating xAJAX on its own! Let me try to explain...
If your component is com_example then you would create a PHP file at:
 
/components/com_example/xajax.example.php
 
in that file you need at the very minimum:
 
<?php
/* Stop direct access */
defined( '_VALID_MOS' ) or die( 'Restricted access' );
define('_XAJAX_EXAMPLE', dirname(__FILE__));

$xajaxFunctions[] = array('todo', _XAJAX_EXAMPLE);
$xajaxFunctions[] = array('helloWorld', _XAJAX_EXAMPLE);

function todo($args=null){
    $objResponse = new xajaxResponse();
    $objResponse->addAlert('TODO');
    return $objResponse->getXML();
}
 
function helloWorld($args=null){
    $objResponse = new xajaxResponse();
    $objResponse->addAlert('Hellow World');
    return $objResponse->getXML();
}
 
?> 
 
Tags: developers, xajax,
Click to add your tags...,