我为我的问题找到了其他解决方案。这项工作也可以通过内容插件事件(触发器)来完成。一段代码来自components/com_content/views/article/view.html.php
:
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$this->params, $offset));
$item->event = new stdClass();
$results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$this->params, $offset));
$item->event->afterDisplayTitle = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->afterDisplayContent = trim(implode("\n", $results));
所以我们实际上可以从我们的字符串中创建一个对象并将其传递给这些触发器。结果,我们获得了像文章一样呈现的内容,并具有其主要功能。
关于它的更多信息:
http://www.inmotionhosting.com/support/edu/joomla-25/create-plugin/content-plugin-events
https://groups.google.com/forum/#!msg/joomla-dev-cms/VZVurjiZWIs /9Vr45KS2LTMJ