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

查看:19
本文介绍了在 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天全站免登陆