Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I managed to solve this problem as follows.</p> <p>There were two separate issues happening.</p> <p>Firstly, The v1.6 section did not have the "$option" parameter properly initialised. Thanks to user hbit in <a href="https://stackoverflow.com/questions/7213012/access-joomla-1-6-object-from-external-php" title="Linked Query">this query I made</a>, I was able to solve that. by changing the code as follows:</p> <pre><code>// Dispatch the application. $option = JRequest::getCmd('option'); $app-&gt;dispatch($option); </code></pre> <p>However, that did not solve the issue and the code was still crashing at the 'ob_start' point.</p> <p>Secondly, I couldn't get to the actual reason for the crash but went for a workaround. Since the ob_start bit in question, located in /libraries/joomla/application/component/helper.php, is only there to gather a component output into a variable, I worked around it by pulling the code that '$app->dispatch($option)' fires into my file and amended the problem section.</p> <p>First, I modified the main section as follows:</p> <pre><code>// Dispatch the application. $option = JRequest::getCmd('option'); /** The process crashes here for some reason * (See https://stackoverflow.com/questions/7039162/). * So we comment out the Joomla! function, pull the code in here and * push the component content into the Joomla document buffer ourselves. **/ //$app-&gt;dispatch($option); $this-&gt;joomdispatch($option); </code></pre> <p>I then wrote a 'joomdispatch' function as follows:</p> <pre><code>private function joomdispatch($option) { /************************ * This is pulled from function 'render' * in /libraries/joomla/application.php ************************/ $document = JFactory::getDocument(); $document-&gt;setTitle(JApplication::getCfg('sitename'). ' - ' .JText::_('JADMINISTRATION')); $document-&gt;setDescription(JApplication::getCfg('MetaDesc')); /************************ * This is pulled from function 'renderComponent' * in /libraries/joomla/application/component/helper.php * Function 'renderComponent' is called by the * '$contents = JComponentHelper::renderComponent($component);' line * We exclude that line and jump to the function code ************************/ // Initialise variables. $app = JFactory::getApplication(); // Load template language files. $template = $app-&gt;getTemplate(true)-&gt;template; $lang = JFactory::getLanguage(); $lang-&gt;load('tpl_'.$template, JPATH_BASE, null, false, false) || $lang-&gt;load('tpl_'.$template, JPATH_THEMES."/$template", null, false, false) || $lang-&gt;load('tpl_'.$template, JPATH_BASE, $lang-&gt;getDefault(), false, false) || $lang-&gt;load('tpl_'.$template, JPATH_THEMES."/$template", $lang-&gt;getDefault(), false, false); $scope = $app-&gt;scope; //record the scope $app-&gt;scope = $option; //set scope to component name // Build the component path. $option = preg_replace('/[^A-Z0-9_\.-]/i', '', $option); $file = substr($option, 4); // Define component path. define('JPATH_COMPONENT', JPATH_BASE.DS.'components'.DS.$option); define('JPATH_COMPONENT_SITE', JPATH_SITE.DS.'components'.DS.$option); define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR.DS.'components'.DS.$option); // get component path if ($app-&gt;isAdmin() &amp;&amp; file_exists(JPATH_COMPONENT.DS.'admin.'.$file.'.php')) { $path = JPATH_COMPONENT.DS.'admin.'.$file.'.php'; } else { $path = JPATH_COMPONENT.DS.$file.'.php'; } $task = JRequest::getString('task'); // Load common and local language files. $lang-&gt;load($option, JPATH_BASE, null, false, false) || $lang-&gt;load($option, JPATH_COMPONENT, null, false, false) || $lang-&gt;load($option, JPATH_BASE, $lang-&gt;getDefault(), false, false) || $lang-&gt;load($option, JPATH_COMPONENT, $lang-&gt;getDefault(), false, false); // Handle template preview outlining. $contents = null; // Get component html /************************ * This has been edited from the native 'ob_start'. * Could use curl as well ***********************/ $contents = file_get_contents($this-&gt;joomUrl . '/index.php?' . $this-&gt;joomQS); // Build the component toolbar jimport('joomla.application.helper'); if (($path = JApplicationHelper::getPath('toolbar')) &amp;&amp; $app-&gt;isAdmin()) { // Get the task again, in case it has changed $task = JRequest::getString('task'); // Make the toolbar include_once $path; } $app-&gt;scope = $scope; //revert the scope /************************ * Back to function 'renderComponent' code * to complete process ************************/ $document-&gt;setBuffer($contents, 'component'); // Trigger the onAfterDispatch event. JPluginHelper::importPlugin('system'); JApplication::triggerEvent('onAfterDispatch'); } </code></pre> <p>With this, everything works fine. Didn't get to the bottom of the (strange) error but managed to get around it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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