我有一个自定义组件,实际上有几个。每次都会有开头原料和硬编码的HTML和结束他们的/view/default.php
从组件获取硬编码值插入Joomla 3.x
我有一个系统插件,需要得到这个网站,并在某些情况下,将其更改为别的东西,可以在后端管理。作为一个内容插件,这在所有com_content文章中都能正常工作,但它被组件忽略,我的理解是系统插件可以做到这一点,但我无法将数据导入插件并返回它
组件文本示例
jimport('joomla.plugin.plugin');
class plgSystemMyplugin extends JPlugin {
function onBeforeRender() {
if (JFactory::getDocument()->getType() != 'html') {
return;
}
else {
$document=JFactory::getDocument();
$document->addCustomTag('<!-- System Plugin has been included (for testing) -->');
$document=JResponse::getBody();
$bob=JResponse::getBody();
$db = &JFactory::getDbo();
$db->setQuery('SELECT 1, 2 FROM #__table');
$results = $db->loadRowList();
$numrows=count($results);
if($numrows >0) {
foreach($results as $regexes) {
$document = str_replace($regexes[0],$regexes[1],$document);
}
return $document;
}
else {
$document = 'error with plugin';
}
JResponse::setBody($document);
return $document;
}
}
}
此刻$数据返回具有“一键1个值(字符串)的阵列:$文本1,$文本2在文档的顶部)
JPluginHelper::importPlugin('system');
JPluginHelper::importPlugin('plgSystemMyplugin');
$dispatcher =& JDispatcher::getInstance();
$data = array($text1, $text2); // any number of arguments you want
$data = $dispatcher->trigger('onBeforeRender', $data);
<article>
<div class="spacer" style="height:25px;"></div>
<div class="page_title_text">
<h1>title</h1>
<?php var_dump($data); ?>
</div>
<section>
我的插件限定“(空白/空白)。
但不是我期望的数据库中的数据。
简单来说我有我的文件,我的数据库{sometext}
,它应该返回
<p>my other text</p>
你能帮助
?
谢谢
感谢这个,我有'$ document-> addCustomTag('<! - 系统插件已包含(用于测试) - >');'在系统插件代码中,并且正在输出到屏幕。它正确安装,名称和位置相匹配,但似乎没有创建任何进一步的屏幕。 – ChelseaStats
我添加了更新。 –
'$ bob'有一些我正在做的调试,但在整个过程中都使用了'$ document',包括上面的代码将body分配给'$ bob',它也被分配到'$ document',但仍然无法获得这个插件改变原始内容。感谢您的帮助,但。 :-) – ChelseaStats