TYPO3中的用户特定内容和缓存

时间:2017-11-17 15:00:47

标签: caching typo3

如何在TYPO3中显示未缓存的fe_user数据?根据{{​​3}}。 如果用户登录,ViewHelper会设置$ GLOBALS [' TSFE'] - > no_cache = 1.是否有更好的方法?因为不是整个页面不应该被缓存,只是它的某些部分。

2 个答案:

答案 0 :(得分:1)

不幸的是,这是不可能的。

最好的方法是,使用名为eID或TypeNum的AJAX呈现未缓存的fe_user数据,并完整地缓存整个页面。 像这个: http://www.typo3-tutorials.org/cms/typo3-und-ajax-wie-geht-das.html

答案 1 :(得分:1)

您的示例代码已禁用整个页面的缓存。但您只需要为显示用户特定数据的部分禁用缓存。除了缓存中的任何部分之外,您还需要选择是否仅缓存

  • 一个内容元素(特别是对于插件,这是标准行为:只是在ext_localconf.php中声明您的插件无法访问)
  • 一列(确保在你的typoscript中使用COA_INT(或其他未缓存的对象))
  • 一个viewhelper(让你的viewhelper无法访问[1]或使用来自EXT的v:render.uncache() VH:vhs)

[1] viewhelper派生自AbstractConditionViewHelper,它使用Compilable接口来缓存结果,必须重写AbstractConditionViewHelper中的compile()方法并返回常量

\TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION
像这样:

public function compile(
    $argumentsVariableName,
    $renderChildrenClosureVariableName,
    &$initializationPhpCode,
    \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode,
    \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler
) {
    parent::compile(
        $argumentsVariableName,
        $renderChildrenClosureVariableName,
        $initializationPhpCode,
        $syntaxTreeNode,
        $templateCompiler
    );

    return \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION;
}
相关问题