Injecting into the Joomla context

Recently while working on a new Joomla component we felt it necessary to build a simple standalone php page that allowed us to experiment without impacting the core component we are developing. We found ourselves faced with an interesting dilemma. We are developing a Joomla component and our requirement is to use the build it Joomla methods to access the database; however our standalone php page will not natively have access to the Joomla environment.

To work around this we found you only need to include the following items in your standalone php page to gain access to all of the Joomla database calls.

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//GET ME INTO THE JOOMLA CONTEXT
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

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

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//JOOMLA CONTEXT ACHIEVED
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Well that is all you need to the top of your PHP file to gain access to the Joomla 1.5 database environment.

News

Themes - Templats

Visit our New Shop Store where you will find Themes and Templates for all Web Site Frameworks. Some are FREE!

  • Joomla Templates
  • PrestaShop Themes
  • Dot Net-ASP.NET  Templates
  • HTML Templates
  • Blogger Templates
  • Drupal Templates
  • WordPress Themes
  • DotNetNuke Templates
Let us host it and market your site today!

OTG Group Loves Joomla

  What is Joomla? Joomla is an open source content management solution (CMS) that provides an excellent platform that can be extended to meet the demands of all customers both small and big.

Read more...

Who Is Online

We have 6 guests online