Note that there are some explanatory texts on larger screens.

plurals
  1. POJoomla 1.6 External PHP Interaction Issue
    primarykey
    data
    text
    <p>I am new to working with Joomla and I am adapting an external php class I wrote for v1.5. Without going into all the details, basically, I use a function to load the Joomla environment after which everything in Joomla is available to the class. This is essentially done using the index.php file.</p> <p>It works fine with v1.5 and has done for a while but trying to adapt it for v1.6, it falls over. </p> <p>Here is the function:</p> <pre><code> private function loadJoomla() { $path_base = rtrim($this-&gt;joomFullPath, '/'); // Set flag that this is a parent file define( '_JEXEC', 1 ); define( 'DS', DIRECTORY_SEPARATOR ); switch ($joomlaVersion) { case 'v1.6': if (file_exists($path_base . '/defines.php')) { include_once $path_base . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', $path_base); require_once JPATH_BASE.'/includes/defines.php'; } require_once JPATH_BASE.'/includes/framework.php'; // Mark afterLoad in the profiler. JDEBUG ? $_PROFILER-&gt;mark('afterLoad') : null; // Instantiate the application. $app = JFactory::getApplication('site'); // Initialise the application. $app-&gt;initialise(); // Mark afterIntialise in the profiler. JDEBUG ? $_PROFILER-&gt;mark('afterInitialise') : null; // Route the application. $app-&gt;route(); // Mark afterRoute in the profiler. JDEBUG ? $_PROFILER-&gt;mark('afterRoute') : null; // Dispatch the application. $app-&gt;dispatch(); // Mark afterDispatch in the profiler. JDEBUG ? $_PROFILER-&gt;mark('afterDispatch') : null; // Render the application. $app-&gt;render(); // Mark afterRender in the profiler. JDEBUG ? $_PROFILER-&gt;mark('afterRender') : null; // Return the response. return $app; break; case 'v1.5': // PREPARE define('JPATH_BASE', $path_base); require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); JDEBUG ? $_PROFILER-&gt;mark( 'afterLoad' ) : NULL; // CREATE THE APPLICATION $GLOBALS['mainframe'] =&amp; JFactory::getApplication('site'); // INITIALISE THE APPLICATION /* set the language */ $GLOBALS['mainframe']-&gt;initialise(); JPluginHelper::importPlugin('system'); /* trigger the onAfterInitialise events */ JDEBUG ? $_PROFILER-&gt;mark('afterInitialise') : NULL; $GLOBALS['mainframe']-&gt;triggerEvent('onAfterInitialise'); // ROUTE THE APPLICATION $GLOBALS['mainframe']-&gt;route(); /* authorization */ $GLOBALS['Itemid'] = JRequest::getInt( 'Itemid'); $GLOBALS['mainframe']-&gt;authorize($GLOBALS['Itemid']); /* trigger the onAfterRoute events */ JDEBUG ? $_PROFILER-&gt;mark('afterRoute') : NULL; $GLOBALS['mainframe']-&gt;triggerEvent('onAfterRoute'); // DISPATCH THE APPLICATION $GLOBALS['option'] = JRequest::getCmd('option'); $GLOBALS['mainframe']-&gt;dispatch($GLOBALS['option']); /* trigger the onAfterDispatch events */ JDEBUG ? $_PROFILER-&gt;mark('afterDispatch') : NULL; $GLOBALS['mainframe']-&gt;triggerEvent('onAfterDispatch'); // RENDER THE APPLICATION $GLOBALS['mainframe']-&gt;render(); /* trigger the onAfterRender events */ JDEBUG ? $_PROFILER-&gt;mark('afterRender') : NULL; $GLOBALS['mainframe']-&gt;triggerEvent('onAfterRender'); // RETURN THE RESPONSE return JResponse::toString($GLOBALS['mainframe']-&gt;getCfg('gzip')); break; default: return NULL; break; } </code></pre> <p>As said, the v1.5 bit works fine and is just the index.php file with the mainframe variable made global. The v1.6 bit falls over at '$app->dispatch();'.</p> <p>Debugging the flow using 'die' took me to function dispatch in /libraries/joomla/application.php where I found that the fall over point was '$contents = JComponentHelper::renderComponent($component);' which took me to function renderComponent in /libraries/joomla/application/component/helper.php</p> <p>A few 'dies' later, I found the fall over point to be, wait for it, 'ob_start();'. Completely baffled especially since checking in v1.5 code, I can see it is exactly the same as v1.6 here.</p> <p>I suspect the $app scope may be the reason behind this and will appreciate some help. I tried the obvious "$GLOBALS['app']" with no joy.</p> <p>Thanks for taking the time and pointers appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload