Вот простейший системный плагин для Joomla 1.5, который имеет доступ уже к сформированной странице:
Файл sample.php:
<?php
class plgSystemSample extends JPlugin {
function onAfterRender()
{
// пример обработки параметра
if ($this->params->get('enable_replacement', 0) == 0) {
return true;
}
$app =& JFactory::getApplication();
// проверка, что мы не в административной панели
if ($app->getName()!= 'site') {
return true;
}
// получаем текст сформированной страницы
$buffer = JResponse::getBody();
// делаем замены в тексте
$buffer = str_replace('test', 'tost', $buffer);
if ($buffer != '') {
// подменяем текст страницы
JResponse::setBody($buffer);
}
return true;
}
}
и к нему установочный XML-файл sample.xml:
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="system">
<name>System - Sample</name>
<creationDate>04/11/2009</creationDate>
<author>smart</author>
<copyright>Copyright 2009 JoomlaTune.ru All rights reserved!</copyright>
<authorEmail>smart@joomlatune.ru</authorEmail>
<authorUrl>http://www.joomlatune.ru</authorUrl>
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
<version>1.0</version>
<description>Sample system plugin for Joomla 1.5</description>
<files>
<filename plugin="sample">sample.php</filename>
</files>
<params>
<param name="enable_replacement" type="radio" default="0" label="Enable Replacement" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
</params>
</install>
Плагин делает одну простую вещь - заменяет в тексте страницы все слова test на tost.