Search code examples
typo3typoscript

Set levels property for menu_subpages depdending on layout


I have the following typoscript configuration for the menu_subpages object:

tt_content.menu_subpages {
    dataProcessing {
        10 {
            levels = 1
            as = menu
            expandAll = 1
            includeSpacer = 1
        }
    }
}

To give the editor more flexibility I want to set the levels property depending on the selected layout of the content object. I've tried to use the CASE object but this doesn't seem to work:

tt_content.menu_subpages {
    dataProcessing {
        10 {
            levels = CASE
            levels {
                key.field = layout

                default = TEXT
                default.value = 1

                1000 = TEXT
                1000.value = 7
            }
            ...
        }
    }
}

Thanks for any help!


Solution

  • As levels is no object but a property you can't use it as an object.

    Either you change it to an object:

    tt_content.menu_subpages {
        dataProcessing {
            10 {
                levels.cObject = CASE
                levels.cObject {
                   :
                }
                ...
            }
        }
    }
    

    Or you need to set the value inside a typoscript condition.

    tt_content.menu_subpages {
        dataProcessing {
            10 {
                // default:
                levels = 1
                ...
            }
        }
    }
    [page['layout'] == 1000]
    tt_content.menu_subpages.dataProcessing.10.levels = 7
    [page['layout'] = 2000]
    tt_content.menu_subpages.dataProcessing.10.levels = 3
    [global]