I wish to place some code to Joomla when any page is loaded.

With this I produced a module that card inserts code.

I'm attempting to use

// $Id: helper.php

defined('_JEXEC') or die;
jimport( 'joomla.plugin.plugin' );
jimport( 'joomla.environment.response' );

class modInsertCode

    function onAfterRender($params)
            $code = 'some code'; 

            $documentbody = JResponse::getBody();
            $documentbody = str_replace ("</body>", $code." </body>", $documentbody);

            return true;



but JResponse::getBody() returns a clear string. Any ideas, solutions of fixes for this code?


You need to do it utilizing a wordpress plugin, you will not have the ability to get it done utilizing a module since the HTML response is not produced when the code from the module will get performed.

I really hope it assisted!