typoscript backend_layout_next_level not working

一曲冷凌霜 提交于 2019-12-25 12:52:06

问题


I have the following config

page = PAGE
page {
    typeNum = 0
    10 = FLUIDTEMPLATE
    10 {
        templateRootPath = EXT:folder/Resources/Private/Website/Templates/
        partialRootPath = EXT:folder/Resources/Private/Website/Partials/
        layoutRootPath = EXT:folder/Resources/Private/Website/Layout/
        file.stdWrap.cObject = CASE
        file.stdWrap.cObject {
            key.data = levelfield:-1, backend_layout_next_level, slide
            key.override.field = backend_layout

            default = TEXT
            default.value = whatever.html

            1 < .default

            2 = TEXT
            2.value = whatever-else.html
    }
}

Somehow the 'backend_layout_next_level' is not working; it is not sliding down the tree. As a result I have to set a backend_layout for each page which is not what one should expect.

Is there a way of knowing/debugging/finding out what's causing this? I thought it might be something related to a curly brace being in the wrong place (too early, too late or just plain wrong) inside my typoscript. Therefor I looked inside the Typoscript Template Analyzer and found some errors which I've fixed, but the problem still persists.

Thanks already!

Best regards


回答1:


You use have to give the full path to the file as a value in the .file property or you should use .templateName instead and only provide the name (case sensitive!!!) of the template file without suffix.

@see https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html

Note that in your current setting, the uid of the template record must be 1 or 2.

And you can try to use levelfield: -2 instead of levelfield: -1.




回答2:


TBH I never understood this @^$#% CASE syntax... Therefore definitely prefer common condition which works perfect, you must to add custom condition like I showed in other post, so you can use it like:

page {
    typeNum = 0
    10 = FLUIDTEMPLATE
    10 {
        templateRootPath = EXT:folder/Resources/Private/Website/Templates/
        partialRootPath = EXT:folder/Resources/Private/Website/Partials/
        layoutRootPath = EXT:folder/Resources/Private/Website/Layout/
        file = whatever.html
    }
}

[userFunc = user_beLayout(2)]
    page.10.file = whatever-else.html
[userFunc = user_beLayout(3)]
    page.10.file = yet-other.html
[userFunc = user_beLayout(4)]
    page.10.file = etc.html
[end]

Edit - to satisfy some comments

Note: When I say that I don't understand CASE syntax, that doesn't mean that I don't know it... especially that I studied it in details not once, here's the conclusion...

About performance:

Custom conditions solution is faster than using CASE and slide combination as it doesn't involve additional DB queries (slide does), it iterates $GLOBALS['TSFE']->page array, which is already collected, and stops further checks ASAP, so it's cheaper than slide which makes additional queries if it finds slide in TS (doesn't matter if it's required or not) - (examine the code for slide mechanics), so actually conditions are performance-saver not killer :)

Yet more

Using conditions blocks you can change behavior of multiple elements at once (instead writing separate CASE for each) i.e.:

[userFunc = user_beLayout(2)]
    page.10.file = whatever-else.html
    lib.genericMenu >
    config.absRefPrefix = /layout-specific-abs/
    // etc...
[end]

Using CASE syntax you'll need to repeat all these checks for each element... (where's DRY?)

Finally

Both solutions are ... usable especially when using with cached pages, (difference between them will be about teens or maybe in drastic situation hundred milliseconds -conditions will be faster), for uncached pages most probably it will be good idea to set be_layout directly for each pages record in both cases.




回答3:


It is quite some time ago, you probably resolved your issue but here is a working approach:

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        # select different html files for layouts - ref: backend_layout
        file.stdWrap.cObject = TEXT
        file.stdWrap.cObject {
            data = levelfield:-2,backend_layout_next_level,slide
            override.field = backend_layout
            split {
                token = pagets__
                1.current = 1
                1.wrap = |
            }
            wrap = EXT:folder/Resources/Private/Templates/|.html
        }
        layoutRootPath = EXT:folder/Resources/Private/Layouts/
        partialRootPath = EXT:folder/Resources/Private/Partials/
    }
}

or you can pass it as a variable:

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        file = EXT:folder/Resources/Private/Templates/Main.html
        layoutRootPath = EXT:folder/Resources/Private/Layouts/
        partialRootPath = EXT:folder/Resources/Private/Partials/
        variables {

        # BE_Layout
        BE_Layout = COA
        BE_Layout {
            stdWrap.cObject = TEXT
            stdWrap.cObject {
                data = levelfield:-2,backend_layout_next_level,slide
                override.field = backend_layout
                split {
                    token = pagets__
                    1.current = 1
                    1.wrap = |
                }
                wrap = |.html
            }
        }
    }
}


来源:https://stackoverflow.com/questions/33415138/typoscript-backend-layout-next-level-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!