Use Joomla Classes within my php file
I have a joomla site and need an xml generating php script to run within it. The file is called by my module. The module works ok but I cannot get to crea开发者_高级运维te a php file that outputs the code, primarily because I can't use things like$db =& JFactory::getDBO();
Anyone with an experience on this front?
If you are calling a file that is outside of the joomla framework, then you need to create an instance of the joomla application so the code has access to joomla.
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', dirname(__FILE__) );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
This should give you access to the basics.
精彩评论