Joomla plugin fetch entire page content before exiting

With my Joomla plugin, I would like to get and modify all content before creating the result.

function newContent($html)
    {
    $html = "new content";
    return $html;
    }

function onContentPrepare()
    {
    ob_start(array($this, "newContent"));
    return true;
    }

function onContentBeforeDisplay()
    {
    ob_end_flush();
    return true;
    }

      

I tried with onContentAfterDisplay

, but it keeps changing only a small part, not all of the output.

+3


source to share


1 answer


Why don't you just do:

public function onContentPrepare($context, &$article, &$params, $page = 0)
{
     $article->text = "new content";
}

      

?



EDIT

Based on your answer it is possible to change all content / body of the page in the plugin here. Add this method to your plugin:

public function onAfterRender()
{
    $app = JFactory::getApplication();
    $currentBodyToChange = $app->getBody();

    //do something with $currentBodyToChange
    //$bodyChanged is modified $currentBodyToChange

    $app->setBody($bodyChanged);
}

      

+2


source







All Articles