Typo3/Fluid: 使用 uid 和 pid 呈现新闻内容
Typo3/Fluid: Render news content with uid and pid
我在使用流体从外部扩展加载内容时遇到问题。
我想加载所有选定的新闻条目。
如果我调试流体,我会收到以下数据:uid = 2 / pid = 7
但仅此而已,例如标题、正文……
有没有办法使用流畅的 and/or VHS viewhelper 呈现内容?
我需要获取所选新闻条目的所有信息。
记录来自扩展“新闻”,应显示新闻条目的标题和描述。
在我的后端 TCA 中,我通过以下方式访问新闻条目:
'foreign_table' => 'tx_news_domain_model_news',
'MM' => 'tx_news_domain_model_news_ttcontent_mm',
但在我的 Frontend-Rendering 中,我只能访问新闻“uid”和“pid”,仅此而已。
我的 Fluid 代码如下所示:
<f:for each="{entries}" as="entry">
<f:for each="{entry.news}" as="news">
### HERE is only the access to the uid and pid ########
</f:for>
</f:for>
我通过我的控制器 (Classes/Controller) 中的条目:
$entries = $this->entriesRepository->findAll();
$this->view->assign('entries', $entries);
我已经创建了自己的扩展,我想访问扩展“新闻”的条目。
我假设您有 entry
记录的模型,其中 news
是 属性,并且您有自己的 news
记录模型。如果是这样,您需要确保您的 news
模型扩展了新闻扩展的模型。这样所有字段都可用。
因此,在您的 entry
模型中,您将拥有如下内容:
/*
* News
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Your\Extension\Domain\Model\News>
*/
protected $news;
而您的 news
模型 class 定义为:
namespace Your\Extension\Domain\Model;
class News extends \GeorgRinger\News\Domain\Model\News {
如果您不扩展新闻,您也可以从 entry
模型中的新闻扩展直接 link 模型。这样你就不需要自己的 news
模型:
/*
* News
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\News>
*/
protected $news;
我在使用流体从外部扩展加载内容时遇到问题。 我想加载所有选定的新闻条目。
如果我调试流体,我会收到以下数据:uid = 2 / pid = 7
但仅此而已,例如标题、正文……
有没有办法使用流畅的 and/or VHS viewhelper 呈现内容? 我需要获取所选新闻条目的所有信息。
记录来自扩展“新闻”,应显示新闻条目的标题和描述。
在我的后端 TCA 中,我通过以下方式访问新闻条目:
'foreign_table' => 'tx_news_domain_model_news',
'MM' => 'tx_news_domain_model_news_ttcontent_mm',
但在我的 Frontend-Rendering 中,我只能访问新闻“uid”和“pid”,仅此而已。
我的 Fluid 代码如下所示:
<f:for each="{entries}" as="entry">
<f:for each="{entry.news}" as="news">
### HERE is only the access to the uid and pid ########
</f:for>
</f:for>
我通过我的控制器 (Classes/Controller) 中的条目:
$entries = $this->entriesRepository->findAll();
$this->view->assign('entries', $entries);
我已经创建了自己的扩展,我想访问扩展“新闻”的条目。
我假设您有 entry
记录的模型,其中 news
是 属性,并且您有自己的 news
记录模型。如果是这样,您需要确保您的 news
模型扩展了新闻扩展的模型。这样所有字段都可用。
因此,在您的 entry
模型中,您将拥有如下内容:
/*
* News
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Your\Extension\Domain\Model\News>
*/
protected $news;
而您的 news
模型 class 定义为:
namespace Your\Extension\Domain\Model;
class News extends \GeorgRinger\News\Domain\Model\News {
如果您不扩展新闻,您也可以从 entry
模型中的新闻扩展直接 link 模型。这样你就不需要自己的 news
模型:
/*
* News
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\GeorgRinger\News\Domain\Model\News>
*/
protected $news;