0
votes

I'm trying to build from scratch a website with typo3 9.5 and setting up different template files for different pages. How do I achieve this?

I'm following the tutorial from https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/TypoScriptConfiguration/Index.html and also tried the solution with no success provided at Typo3 Fluid Templates How to add multiple templates

Now all pages load the Default template and if I set the default cObject to Alternative, it loads the Alternative.html to all pages, even when the TCA at Typo3 is set correctly for each page:

  • All Pages Back-end Layout to [Default]
  • Contact set to [Alternative].

_

page = PAGE
page {
   typeNum = 0

   // Part 1: Fluid template section
   10 = FLUIDTEMPLATE
   10 {
      templateName = TEXT
      templateName.stdWrap.cObject = CASE
      templateName.stdWrap.cObject {
        key.data = pagelayout

        pagets__default = TEXT
        pagets__default.value = Default

        default = TEXT
        default.value = Default

        pagets__alternative = TEXT
        pagets__alternative.value = Alternative

        alternative = TEXT
        alternative.value = Alternative

      }


      templateRootPaths {
         0 = EXT:photo/Resources/Private/Templates/Page/
         1 = {$page.fluidtemplate.templateRootPath}
      }
      partialRootPaths {
         0 = EXT:photo/Resources/Private/Partials/Page/
         1 = {$page.fluidtemplate.partialRootPath}
      }
      layoutRootPaths {
         0 = EXT:photo/Resources/Private/Layouts/Page/
         1 = {$page.fluidtemplate.layoutRootPath}
      }
      dataProcessing {
      10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
      10 {
         levels = 1
         includeSpacer = 1
         as = mainnavigation
         }
      }
   }

I want to use for instance a default.html template for all pages except contact page, which will have it's own template ( site_template/Resources/Private/Templates/Page/Alternative.html ).

1
So why don’t you create two partials, one for all the other pages and one only for contact and then on your default.html a condition which gets the uid and load the partial that you need? - Aristeidis Karavas
Your proposal wouldn't let me use different back-end layouts and change the entire page structure, like the menu or the footer. In typo3 6.2 I used to build pages like this. - Luke Marks
Why would it not? You can use whatever layout you want. On the partials you just define the col pos to where the data have to be saved. You can actually define which layout you would like to have, so the footer or header would be different as well... - Aristeidis Karavas
So you're telling me to use partials as if they were templates? Well, that would be a fast solution. But still, I'm interested into learning how to use templates. I'm not conformed with just knowing a work-around. I'm really confused by the documentation as per older versions of typo3, I did everything very differently. Thanks for the idea anyway, is good to know! - Luke Marks

1 Answers

1
votes

First:
you should use higher numbers for the paths to your templates.
The higher the number the higher the priority for overriding files with the same name.

second:
there is no field pagelayout. either use layout or better backend_layout and backend_layout_next_level (example configuration with the full usage of configuration for subpages).

Your key values (pagets__default and pagets__alternative) already hint to the usage of backend_layout (pagets__* is the usual key for backend layouts defined in page TSconfig).

Probably the example in the documentation needs some correction. (Pull-request commited)