Created
June 20, 2012 15:47
-
-
Save gbluma/2960583 to your computer and use it in GitHub Desktop.
Use Joomla outside of Joomla
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
define( '_JEXEC', 1 ); | |
define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/' ) ); | |
define( 'DS', DIRECTORY_SEPARATOR ); | |
// PREPARE | |
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); | |
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); | |
// CREATE THE APPLICATION ------------------------------------------ | |
$mainframe = JFactory::getApplication('site'); | |
// INITIALISE THE APPLICATION -------------------------------------- | |
/* set the language */ | |
$mainframe->initialise(); | |
JPluginHelper::importPlugin('system'); | |
/* trigger the onAfterInitialise events */ | |
$mainframe->triggerEvent('onAfterInitialise'); | |
// ROUTE THE APPLICATION ------------------------------------------- | |
$mainframe->route(); | |
/* authorization */ | |
$Itemid = JRequest::getInt( 'Itemid'); | |
$mainframe->authorize($Itemid); | |
/* trigger the onAfterRoute events */ | |
$mainframe->triggerEvent('onAfterRoute'); | |
// DISPATCH THE APPLICATION ---------------------------------------- | |
$option = JRequest::getCmd('option'); | |
$mainframe->dispatch($option); | |
/* trigger the onAfterDispatch events */ | |
$mainframe->triggerEvent('onAfterDispatch'); | |
// RENDER CONTENT -------------------------------------------------- | |
// tell Joomla to build it's content | |
$mainframe->render(); | |
/* trigger the onAfterRender events */ | |
$mainframe->triggerEvent('onAfterRender'); | |
// Render the full page as per Joomla | |
// $component = JResponse::toString($mainframe->getCfg('gzip')); | |
// COPY CONTENTS OF COMPONENT -------------------------------------- | |
$document = JFactory::getDocument(); | |
$component = $document->getBuffer('component'); | |
// this will keep us from jumping out of the test environment | |
$component = str_replace("index.php", "test2.php", $component); | |
//----------- | |
// don't forget all CSS/JS will have to be added manually | |
?> | |
<body style="background-color:#eee; padding-top: 100px"> | |
<h1>Everything In White is Component</h1> | |
<div style="width: 800px; margin: 0 auto; background-color: #fff;"> | |
<?php echo $component ?> | |
</div> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment