TYPO3流体:如何使用多个模板?

问题描述

在较早的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__”就可以了,如果考虑一下的话,这似乎很简单。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...