如何在 StandaloneView 中渲染 INT_SCRIPT?
How to render INT_SCRIPT in StandaloneView?
我正在使用 cObject ViewHelper 在独立视图中呈现 TypoScript 对象。该 TS 对象当前从其他页面获取 tt_content。但是结果有 INT_SCRIPT 标记而不是真正的内容。
这是我关于如何制作独立视图、模板和 TypoScript 的代码:
内部控制器:
public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html', $noCache = TRUE) {
if ( $noCache === TRUE ) $GLOBALS['TSFE']->set_no_cache();
// Get standalone view
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$view = $this->objectManager->get(StandaloneView::class);
$view->getRequest()->setControllerExtensionName($this->extensionName);
$view->setFormat($fileExt);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setTemplate($template);
// Render view
$view->assignMultiple($variables);
return $view->render();
}
打字错误:
lib.myContent = COA
lib.myContent {
10 = CONTENT
10 {
table = tt_content
select {
orderBy = sorting
where = 0
where.wrap = colPos=|
pidInList.field = uid
}
}
}
流体:
<f:for each="{myvars}" as="myvar" iteration="it">
<f:cObject typoscriptObjectPath="lib.myContent" data="{uid:'{myvar.uid}'}" />
</f:for>
我无法更改要缓存的页面上所有未缓存的元素(如内容元素/插件)。
那么我如何解析包括非缓存内容的独立视图而不插入 INT_SCRIPT 标记?
谢谢你的付出!
找到解决办法。也许这不是解决该问题的最佳方法。但目前它工作正常。
public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html') {
// Get standalone view
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$view = $this->objectManager->get(StandaloneView::class);
$view->getRequest()->setControllerExtensionName($this->extensionName);
$view->setFormat($fileExt);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setTemplate($template);
// Render view
$view->assignMultiple($variables);
// Handle the INT_SCRIPT markers
$content = $view->render();
$contentBak = $GLOBALS['TSFE']->content;
$GLOBALS['TSFE']->content = $content;
$GLOBALS['TSFE']->INTincScript();
$content = $GLOBALS['TSFE']->content;
$GLOBALS['TSFE']->content = $contentBak;
unset($contentBak);
return $content;
}
供您参考。我需要它来处理页面中的内容并通过邮件发送它们或使用外部工具呈现 pdf。但是某些内容或页面仅对当前用户可用(不是组或其他用户)。而且我不想在控制器或其他地方登录该用户。我认为这是处理该问题的最佳案例。
仍然欢迎其他解决方案:-)
我正在使用 cObject ViewHelper 在独立视图中呈现 TypoScript 对象。该 TS 对象当前从其他页面获取 tt_content。但是结果有 INT_SCRIPT 标记而不是真正的内容。
这是我关于如何制作独立视图、模板和 TypoScript 的代码:
内部控制器:
public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html', $noCache = TRUE) {
if ( $noCache === TRUE ) $GLOBALS['TSFE']->set_no_cache();
// Get standalone view
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$view = $this->objectManager->get(StandaloneView::class);
$view->getRequest()->setControllerExtensionName($this->extensionName);
$view->setFormat($fileExt);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setTemplate($template);
// Render view
$view->assignMultiple($variables);
return $view->render();
}
打字错误:
lib.myContent = COA
lib.myContent {
10 = CONTENT
10 {
table = tt_content
select {
orderBy = sorting
where = 0
where.wrap = colPos=|
pidInList.field = uid
}
}
}
流体:
<f:for each="{myvars}" as="myvar" iteration="it">
<f:cObject typoscriptObjectPath="lib.myContent" data="{uid:'{myvar.uid}'}" />
</f:for>
我无法更改要缓存的页面上所有未缓存的元素(如内容元素/插件)。
那么我如何解析包括非缓存内容的独立视图而不插入 INT_SCRIPT 标记?
谢谢你的付出!
找到解决办法。也许这不是解决该问题的最佳方法。但目前它工作正常。
public function renderStandaloneView($template = 'View/Show', $variables = array(), $fileExt = 'html') {
// Get standalone view
$configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$view = $this->objectManager->get(StandaloneView::class);
$view->getRequest()->setControllerExtensionName($this->extensionName);
$view->setFormat($fileExt);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setTemplateRootPaths($configuration['view']['templateRootPaths']);
$view->setTemplate($template);
// Render view
$view->assignMultiple($variables);
// Handle the INT_SCRIPT markers
$content = $view->render();
$contentBak = $GLOBALS['TSFE']->content;
$GLOBALS['TSFE']->content = $content;
$GLOBALS['TSFE']->INTincScript();
$content = $GLOBALS['TSFE']->content;
$GLOBALS['TSFE']->content = $contentBak;
unset($contentBak);
return $content;
}
供您参考。我需要它来处理页面中的内容并通过邮件发送它们或使用外部工具呈现 pdf。但是某些内容或页面仅对当前用户可用(不是组或其他用户)。而且我不想在控制器或其他地方登录该用户。我认为这是处理该问题的最佳案例。
仍然欢迎其他解决方案:-)