Search code examples
typo3typo3-9.x

Backend layout and typoscript not working for Basic2column in TYPO3


I have created a backend layout with the name "doubleColumn". Now in the backend admin panel, I have 2 columns left and right. I have added some dummy content left and right column. But when I write typoscript for the doublecolumn template. Then it shows me an error to me in the front end. How can I fix this bug?

This is the error I am getting

Oops, an error occurred! Tried resolving a template file for controller action "Standard->index" in the format ".html", but none of the paths contained the expected template file (). No paths configured.

More information regarding this error might be available online.

Basic2ColumnPage.html

<div class="left-column">
    <f:format.raw>{Leftcontent}</f:format.raw>
</div>
<div class="right-column">
    <f:format.raw>{Rightcontent}</f:format.raw>
</div>

DoubleColumn is a page name and I have added this typoscript in DoubleColumn template

page = PAGE
page {
  10 = FLUIDTEMPLATE
  10 {
    file.stdWrap.cObject = CASE
    file.stdWrap.cObject {
      key.data = levelfield:-1, backend_layout_next_level, slide
      key.override.field = backend_layout
      1 = Text
      1.value = fileadmin/templates/demo/Resources/Private/Layouts/Basic2ColumnPage.html
    }
    variables {        
      Leftcontent >StyleSheet.content.get
      Leftcontent.select.where = colPos=0          
      Rightcontent < styles.content.get
      Rightcontent.select.where = colpos=1
    }
  }
}

This is my Backend Layouts(TS-config)

mod.web_layout.BackendLayouts {
  exampleKey {
    title = Example
    icon = EXT:example_extension/Resources/Public/Images/BackendLayouts/default.gif
    config {
      backend_layout {
        colCount = 2
        rowCount = 1
        rows {
          1 {
            columns {
              1 {
                name = Left content
                colPos = 0
              }
              2 {
                name = Right content
                colPos = 1
              }
            }
          }
        }
      }
    }
  }
}

Solution

  • Don't do it too complicated. The property file is possible but not very flexible. and you missed a configuration for your new (backend_)layout.
    Layouts defined in TSconfig are prefixed with pagets__ (two underscores!).

    A clean way of configuration would be:

    1. use pathes:
        10 {
            templateRootPaths.1 = EXT:site_ext/Resources/Private/Templates
            partialRootPaths.1 = EXT:site_ext/Resources/Private/Partials
            layoutRootPaths.1 = EXT:site_ext/Resources/Private/Layouts    
            :
    
    1. only specify the name of the template (you don't need a file extension):
            :
            templateName = TEXT
            templateName.cObject = CASE
            templateName.cObject {
                key.data = levelfield:-1, backend_layout_next_level, slide
                key.override.field = backend_layout
    
                #Default Template
                default = TEXT
                default.value = Default
    
                1 = TEXT
                1.value = Basic2ColumnPage
    
                pagets__Example = TEXT
                pagets__Example.value = Example
           }
           :
    

    You could use the value in the fields immediately, but then your templates need to have special names, or you must strip of the prefix. And make sure what happens if no matching template exist.