Once I need to have Joomla core class in external files, answer can be found here. To repeat myself, here’s minimum code required to have Joomla functionality in our own file.
<?php //define constant define( '_JEXEC', 1 ); define( 'DS', DIRECTORY_SEPARATOR ); //you need to 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'); //in this point, you're ready to use joomla functionality //example: initialize database object $db = JFactory::getDBO(); //or import plugin helper JLoader::import('joomla.plugin.helper'); //to test whether some plugins is enabled $pluginenabled = &JPluginHelper::isEnabled('authentication', 'joomla'); |
Happy coding!
Leave a Reply