在 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.
相关文章