|
How to integrate Joomla framework? |
|
|
|
|
Written by Bernard Gilly
|
|
Sunday, 21 June 2009 08:21 |
How to integrate Joomla framework in external script?
This question has often been asked for incorporating new rules in AlphaUserPoints with external scripts to Joomla!. The method is quite simple and I'll give you the details here.
Edit the script you wish to modify and put the following at the beginning of the file:
<?php
define( '_JEXEC', 1 );
// real path depending on the type of server
// change the number of returns/level needed in your path relative to the position of your script in your directory
if (stristr( $_SERVER['SERVER_SOFTWARE'], 'win32' )) {
define( 'JPATH_BASE', realpath(dirname(__FILE__).'\..\..\..\..' ));
} else define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../..' ));
define( 'DS', DIRECTORY_SEPARATOR );
// loading framework of Joomla!
require_once ( JPATH_BASE.DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE.DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
// if need a specific language component, you can load it here
jimport( 'joomla.plugin.plugin' );
JPlugin::loadLanguage( 'com_xxxxxxxxx' );
// original code here or your code continue here ...
?>
|