Last Updated: February 25, 2016
·
1.034K
· jeremyrajan

Extending Joomla Functions to external pages

Include the below code at the top of the PHP page.

//define constant
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );


// adjust joomla path according to your joomla installation
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] . DS . 'joomla' );

//include joomla core files
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );

//create application
$mainframe =& JFactory::getApplication('site');

//joomla functionality has been included!

//Now we initialize database object
$db = JFactory::getDBO();

//Importing the Plugin Helper
JLoader::import('joomla.plugin.helper');

// test whether some plugins is enabled
$pluginenabled = &JPluginHelper::isEnabled('authentication', 'joomla');

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside