Joomla 2.5 渲染 com_content 组件输出 [英] Joomla 2.5 render com_content component output

查看:20
本文介绍了Joomla 2.5 渲染 com_content 组件输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从外部脚本渲染 Joomla 内容?例如,我有一些 html 字符串,我想将其传递给 com_content 组件,以使所有内容插件和模块功能可用.我想我应该使用 JDocumentRendererComponent 类.我的外部文件中的代码:

is it possible to render Joomla content from external script? For example I have some html string, which I want to pass to com_content component, to make all content plugin and module features available. I think I should use JDocumentRendererComponent class. Code in my external file:

<?php

require_once ('framework.php'); //loading joomla framework

jimport('joomla.document.html.renderer.component');

$contentHtml = '<p>Some content html</p>';

echo JDocumentRendererComponent::render('com_content',array(),$contentHtml);

?>

我得到的是最后一行的错误:

What I get is error on the last line:

致命错误:找不到JDocumentRendererComponent"类...

我做错了什么?有任何想法吗?

What Im doing wrong? Any ideas?

推荐答案

我为我的问题找到了其他解决方案.这项工作也可以通过内容插件事件(触发器)来完成.components/com_content/views/article/view.html.php 中的一段代码:

I found other solution for my question. The job can be also done by content plugin events (triggers). The piece of code from 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("
", $results));

$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->beforeDisplayContent = trim(implode("
", $results));

$results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$this->params, $offset));
$item->event->afterDisplayContent = trim(implode("
", $results));

所以我们实际上可以从我们的字符串中创建一个对象并将其传递给这些触发器.因此,我们将内容呈现为具有主要功能的文章.

So we can actually make an object from our string and pass it to these triggers. As a result we are getting content rendered like an article, with its major functionality.

关于它的更多信息:

http://www.inmotionhosting.com/support/edu/joomla-25/create-plugin/content-plugin-eventshttps://groups.google.com/forum/#!msg/joomla-dev-cms/VZVurjiZWIs/9Vr45KS2LTMJ

这篇关于Joomla 2.5 渲染 com_content 组件输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆