TYPO3 FLUID:如何使用多个模板?

TYPO3 FLUID: How to use more than one template?

在旧的 TYPO3 版本中有一个简单的方法,可以有许多不同的模板,但它似乎不再适用于 TYPO3 9.5。

10 = FLUIDTEMPLATE
10 {
    templateName = TEXT
    templateName.stdWrap.cObject = CASE
    templateName.stdWrap.cObject {
        data = pagelayout

        2 = TEXT
        2.value = 2Col2Row

        default = TEXT
        default.value = Default 
    }
    
    variables{          
        
        pageTitle = TEXT
        pageTitle.data = page:title
        siteTitle = TEXT
        siteTitle.data = TSFE:tmpl|setup|sitetitle
        rootPage = TEXT
        rootPage.data = leveluid:0
        logo = IMAGE
        logo {
            file = EXT:myExt/Resources/Public/Icons/mylogo_icon.png
            height = 73
            width = 60  
            params = class="navbar-brand-logo-normal" style="max-height: 100%;margin-right:15px;"
            alt = Home
            linktitle = 
        }           
    
        content < styles.content.get
        content.select.where = colPos = 0
        topright < styles.content.get
        topright.select.where = colPos = 5
        bottomleft < styles.content.get
        bottomleft.select.where = colPos = 6
        bottomright < styles.content.get
        bottomright.select.where = colPos = 7
    }
    
    dataProcessing {
        10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
        10 { 
            levels = 2
            includeSpacer = 1
            as = mainnavigation             
            #special = directory
            #special.value = 1,193,201          
            special = list
            special.value = 90,194,200,195,201
        }
        20 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
        20 {
            entryLevel = 1
            levels = 2
            expandAll = 0
            includeSpacer = 1
            as = subnavigation
        }
        30 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
        30 {
            special = rootline
            special.range = 0|-1
            includeNotInMenu = 1
            as = breadcrumb
            if {
                value = {$page.theme.breadcrumb.enableLevel}
                value {
                    insertData = 1
                    prioriCalc = 1
                    stdWrap.wrap = |-1
                }
                isGreaterThan {
                    data = level
                }
            }
        }
        40 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
        40 {
            levels = 2
            as = footer             
            special = list
            special.value = 196,197,198,199
        }
    }
    
    templateRootPaths {
        0 = EXT:myExt/Resources/Private/Templates/Page/
    }
    partialRootPaths {
        0 = EXT:myExt/Resources/Private/Partials/Page/
    }
    layoutRootPaths {
        0 = EXT:myExt/Resources/Private/Layouts/Page/
    }
}

includeCSS {
    file1 = EXT:myExt/Resources/Public/Css/bootstrap4-theme.min.css
    fule3 = EXT:myExt/Resources/Public/Css/ext/base.css
    file5 = fileadmin/Resource/services/fontawesome582/css/all.css
}

includeJS {
    jquery = EXT:myExt/Resources/Public/Scripts/jquery.min.js
    bootstrap = EXT:myExt/Resources/Public/Scripts/bootstrap.min.js
    bootstrap = EXT:myExt/Resources/Public/Scripts/bootstrap.navbar.min.js
}
}

路径正在工作,因为它显示了默认页面。我想不通,我想念另一个模板。所有后端布局和模板文件都在它们必须在的地方。

CASE 对象需要 属性 key

试一试:

templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
    key.data = pagelayout
    :

编辑:

您应该检查 key 的值以确定正确的标签。 添加一个新的流体变量:

variables {
    pagelayout = TEXT
    pagelayout.data = pagelayout
    :

然后在你的模板中输出,每次都选择:

<f:debug title="pagelayout">{pagelayout}</f:debug>

在此处 https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/setup.typoscript#L92 查看不需要 CASE 的逻辑。 如果您使用数据库中的后端布局而不是在 PageTS 中定义,请删除 split

啊哈,非常感谢你们的回答和提示 - 这样我就可以搜索正确的东西并找到解决方案。

key.data = pagelayout
            
pagets__standard = TEXT
pagets__standard.value = Default    

pagets__2_col_2_row = TEXT
pagets__2_col_2_row.value = 2Col2Row

default < .pagets__standard

我只需要从后端布局中使用前缀“pagets__”给备选方案命名,如果考虑一下,这似乎很简单。