Perthe
Perthe

Reputation: 1

TYPO3 FLUID: How to use more than one template?

in older TYPO3 Versions there was a simple way, to have many different templates, but it seems this doesn't work in TYPO3 9.5 anymore.

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
}
}

The paths are working for it shows the default page. I can't figure out, what I miss to take another template. All backend layouts and template files are where they have to be.

Upvotes: 0

Views: 390

Answers (3)

Perthe
Perthe

Reputation: 1

Ahhhh, thank you all so much for your answers and hints - so I could search the right things and could find the solution.

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

I only had to give the alternative the name from the backend layout with prefix "pagets__" which seems very simple if one think about it.

Upvotes: 0

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10791

The CASE object needs a property key.

just try:

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

EDIT:

you should inspect the values for your key to decide the correct labels. add a new fluid variable:

variables {
    pagelayout = TEXT
    pagelayout.data = pagelayout
    :

and then output it in your template, which is selected every time:

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

Upvotes: 1

Jonas Eberle
Jonas Eberle

Reputation: 2921

Have a look here https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TypoScript/setup.typoscript#L92 for a logic that does not require CASE. Remove the split if you are using backend layouts from the database instead of defined in PageTS.

Upvotes: 0

Related Questions