我想在加载任何页面时向 Joomla 插入一些代码。
为此,我创建了一个插入代码的模块。
我正在尝试使用
<?php
// $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);
JResponse::setBody($documentbody);
return true;
}
}
?>
但是 JResponse::getBody(); 返回一个空字符串。任何想法,修复此代码的解决方案?
谢谢,