Typo3 如何在StandaloneView中呈现INT_脚本?
我正在使用cObject ViewHelper在独立视图中渲染打字脚本对象。该TS对象当前从其他页面获取tt_内容。但是结果是INT_脚本标记,而不是真正的内容 以下是我关于如何创建独立视图、模板和打字稿的代码:Typo3 如何在StandaloneView中呈现INT_脚本?,typo3,fluid,extbase,typo3-7.6.x,typo3-extensions,Typo3,Fluid,Extbase,Typo3 7.6.x,Typo3 Extensions,我正在使用cObject ViewHelper在独立视图中渲染打字脚本对象。该TS对象当前从其他页面获取tt_内容。但是结果是INT_脚本标记,而不是真正的内容 以下是我关于如何创建独立视图、模板和打字稿的代码: lib.myContent = COA lib.myContent { 10 = CONTENT 10 { table = tt_content select { orderBy = sorting where
lib.myContent = COA
lib.myContent {
10 = CONTENT
10 {
table = tt_content
select {
orderBy = sorting
where = 0
where.wrap = colPos=|
pidInList.field = uid
}
}
}
内部控制器:
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_脚本标记呢
谢谢你做的一切 找到了解决办法。也许这不是解决这个问题的最好办法。但目前它运行良好
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。但某些内容或页面仅对当前用户可用(而不是组或其他用户)。我不想让那个用户在控制器内登录,否则。我认为这是最好的解决办法
其他解决方案仍然受欢迎:-)我认为这不会解决您的整个问题,但是您应该开始从您的方法中删除
$GLOBALS['TSFE']->set_no_cache()
。这将禁用当前请求的所有页面缓存。不要将此set\u no\u cache
用于任何你想发布到野外的东西!谢谢你的提示。我改了。正如预期的那样,它并没有解决我的问题。在过去的10分钟里,我一直在试图弄清楚你在这里想做什么。无济于事。此条件:如果($noCache==TRUE)$GLOBALS['TSFE']->set_no_cache();显然不行。因为如果你的内容被缓存一次,情况甚至不会再被检查。在ext_localconf.php中调用ExtensionUtility::configurePlugin定义了每个动作,如果内容是缓存的,为什么不这么说?您调用StandaloneView只是为了调用内容呈现的打字脚本。天哪。这就是从扩展内部呈现内容的方式:是的,我知道它看起来像一个“垃圾”,只是为了呈现打字稿。我无法向你解释整个项目,但在我的情况下,需要以独立的方式使用它。无论如何,非常感谢你的提示!另一种方法(和您的方法一样)可以是调用ContentRenderObject并在TS对象中使用FLUIDTEMPLATE。