TypoScript在Fluid模板中的最佳用法是什么? [英] What is the best usage of TypoScript in Fluid templates?

查看:83
本文介绍了TypoScript在Fluid模板中的最佳用法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想在Fluid模板中使用TypoScript之类的菜单生成功能,我有两种可能的方法:

If I want to use TypoScript like menu generation in a Fluid template I have two possible ways:

  • 使用TypoScript填充模板的变量.这样做:

  • use the TypoScript to fill a variable for the template. doing it like this:

page.10 = FLUIDTEMPLATE
page.10 {
    templateName = index.html
    // ... define pathes ...
    variables {
        contentMain < styles.content.get
        mainMenu < temp.mainMenu
        :
    }
}

,并且在模板中只需使用变量:

and in the template just use the variable:

<div class="header">
    <div class="logo">{logo->f:format.raw()}</div>
    <div class="main-menu">{mainMenu->f:format.raw()}</div>
</div> 

  • 另一种方法是使用f:cObject ViewHelper来调用TypoScript的一部分.
    TypoScript:

  • the other way is the usage of the f:cObject ViewHelper to call a part of TypoScript.
    the TypoScript:

    page.10 = FLUIDTEMPLATE
    page.10 {
        templateName = index.html
        // ... define pathes ...
        variables {
            contentMain < styles.content.get
            :
        }
    }
    lib.mainMenu < temp.mainMenu
    

    Fluid模板如下所示:

    while the Fluid template looks like this:

    <div class="header">
        <div class="logo">{logo->f:format.raw()}</div>
        <div class="main-menu">
            <f:cObject typoscriptObjectPath="lib.mainMenu />
        </div>
    </div> 
    

  • 所以.我的问题:每种方式的利弊是什么?
    TYPO3的不同版本有区别吗?

    so. My question: what are the pros and cons of each way?
    Are there differences for the different versions of TYPO3?

    推荐答案

    我不同意pgampe的观点,因为这两种方法存在很大差异

    I disagree on the opinion of pgampe as there are big differences regarding those 2 approaches!

    如果您使用的是变量,即使前端中未使用这些内容元素,它们也会被始终呈现.这可能会产生巨大的副作用,而这些副作用确实很难解决.一些例子

    If you are using variables, those are always rendered, even though those content elements are not used in the frontend. This can have huge side effects which are really hard to tackle. Some examples

    • 您在某列的页面上有一些沉重的USER_INT插件,这些插件不再使用了(不再使用).即使它们从未显示,它们仍会被调用
    • 您正在使用EXT:news和功能ExcludeDisplayedNews.如果存在通过变量以某种方式呈现的新闻插件(但从未输出),则呈现并显示的新闻插件会丢失新闻记录
    • You have some heavy USER_INT plugins on a page in a column which is not in use (anymore). those will be still called even though they are never shown
    • You are using EXT:news and the feature ExcludeDisplayedNews. If there is a news plugin rendered somehow via variables (but never outputted), a news plugin which is rendered and shown will miss news records

    这篇关于TypoScript在Fluid模板中的最佳用法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆