Loading an article into a components template in Joomla(在 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 中将文章加载到组件模板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Joomla 中将文章加载到组件模板中


基础教程推荐
- php中的foreach复选框POST 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- php中的PDF导出 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- Web 服务器如何处理请求? 2021-01-01