将文章加载到Joomla中的组件模板中 [英] Loading an article into a components template in Joomla

查看:132
本文介绍了将文章加载到Joomla中的组件模板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文章加载到Joomla框架内的组件模板php代码中.

i would like to load an article into a components templates php code within the Joomla framework.

我可以在php中加载模块,在文章中加载模块,在文章中添加组件,并且..但是我从不希望将文章加载到组件php中.

I can load modules in php, modules in articles, components in articles and and..but i never wanted to load an article into a components php.

有人知道为此的代码段吗?

Does anybody know of a code snippet for that?

感谢任何帮助.

推荐答案

我会在您的视图中加载文章模型,例如

I would load the article model in your view like

JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
$model = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request' => true));
$article = $model->getItem((int) $articleId);

现在,您可以访问文章中所有可用的字段,例如$item->fulltext$item->introtext.看看文章视图在显示该文章之前先检查一下它对本文所做的所有奇特的东西.

Now you can access all the fields which are available in the article like $item->fulltext or $item->introtext. Have a look at the article view to check out all the fancy stuff it does with the article before it displays it.

这篇关于将文章加载到Joomla中的组件模板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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