gpt4 book ai didi

Call to a member function filterAccessiblePageIds() on string(对字符串调用成员函数filterAccessiblePageIds())

转载 作者:bug小助手 更新时间:2023-10-25 20:38:19 30 4
gpt4 key购买 nike



I want to get page content in my function. I am developing an extension for sending newsletters. My goal is to add page content in the mail body. I have created one new scheduler task and in this task I have added one field pageId. Now I want to get this page content in my custom scheduler task. So, I have writen below code.

我想在我的函数中获得页面内容。我正在开发一个用于发送时事通讯的扩展。我的目标是在邮件正文中添加页面内容。我已经创建了一个新的调度程序任务,并且在该任务中添加了一个字段pageID。现在,我希望在我的定制调度程序任务中获得此页面内容。所以,我写了下面的代码。


SendNewslatters.php:

SendNewslatters.php:


$this->initTask();

$selectedGroup = (int)$this->group;
$pageId = (int)$this->pageId;


$renderer = $this->rendererUtility->getFluidRendererForTemplate(
'typo3conf/ext/newslatters/Resources/Private/Templates/Subscribers/Mail/NewslaterMail.html',
'html'
);

$renderer->assign('pageId', $pageId);
$message = $renderer->render();

NewslaterMail.html:

NewslaterMail.html:


<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '0', pageUid: pageId}" />

</html>

Can you please help me here? How can I resolved this error?

你能帮我一下吗?我如何解决此错误?


更多回答

I assume the title of your question is your error message. have you tried a debugging with <f:debug title="all vars">{_all}</f:debug> aside/ instead of your f:cObject call?

我假设您问题的标题是您的错误消息。您是否尝试过使用{_all}side/而不是f:cObject调用进行调试?

优秀答案推荐

The main problem is, that you are not in frontend context and so the TSFE array is missing.

主要问题是,您不在前端上下文中,因此缺少TSFE数组。


There a several approaches to instanciate the TSFE array (Be aware that it is not recommended to do so in the TYPO3 Documentation). But a good way is to use the nnHelper Extension:

有几种实例化TSFE数组的方法(请注意,在TYPO3文档中不建议这样做)。但一个好方法是使用nnHelper扩展:


https://extensions.typo3.org/extension/nnhelpers

Https://extensions.typo3.org/extension/nnhelpers


You can either install the complete Extension or copy the Tsfe Class to your project.

您可以安装完整的扩展,也可以将Tsfe类复制到项目中。


In this solution i installed the Extension.

在此解决方案中,我安装了扩展。


Your task should then look like this:

然后,您的任务应该如下所示:


$pageId = (int)$this->pageId;

$tsfe = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Nng\Nnhelpers\Utilities\Tsfe::class);
$tsfe->get($pageId);

$view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Fluid\View\StandaloneView::class);
$view->setTemplateRootPaths([\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:newslatters/Resources/Private/Templates/Subscribers/Mail'));
$view->setTemplate('NewslaterMail');
$view->assign('pageId', $pageId);
$emailBody = $view->render();

In your template you should pass the pageUid directly and not as array, then you can access it via the current variable in Typoscript. You template should look like this:

在您的模板中,您应该直接传递pageUid,而不是作为数组,然后您可以通过Typoscript中的当前变量访问它。您的模板应该如下所示:


<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:cObject typoscriptObjectPath="lib.newsletterContent" data="{pageId}" />
</html>

To render the content you can then use your own CONTENT lib like this:

要呈现内容,您可以使用自己的内容库,如下所示:


lib.newsletterContent = CONTENT
lib.newsletterContent {
table = tt_content
select {
pidInList.current = 1
}
}

Be aware i used your typo newslater. Normally i would call it newsletter. But that only if someoneelse want to use this solution.

注意,我用的是你的打字错误的新闻。通常我会把它叫做时事通讯。但只有在其他人想使用这种解决方案的情况下才能这样做。


更多回答

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com