简体   繁体   中英

Add custom content element layouts in TYPO3

In TYPO3 I want to add several custom content element layouts to the existing ones of the default content type "Header". The custom layouts should make it possible, to make a header that is originally an H1 header look like H2 or H3, for instance.

So I added this Typoscript code, that is supposed to add the additional options to the interface in the backend:

TCEFORM {
  tt_content {
    layout {
      altLabels {
        0 = abc
        1 = def
        2 = geh
        3 = Layout H1
        4 = Layout H2
        5 = Layout H3
      }
      removeItems = 6,7,8,9,10
    }   
  }
}

As well as this, that should add the CSS classes:

tt_content.stdWrap.innerWrap.cObject = CASE
tt_content.stdWrap.innerWrap.cObject {
    key.field = layout

    3 = TEXT
    3.value = like-h1

    4 = TEXT
    4.value = like-h2

    5 = TEXT
    5.value = like-h3
}

However, of my 3 additional layouts, only one is added to the interface in the backend: 在此输入图像描述

No matter what I try, I can't get the other two layouts to be added to the dropdown list in the backend. What could be a reason for this?

By default there are only 4 Layouts (0 = Standard and 1-3 = Layout 1-3) . By using altLabels you can only rename existing layouts. So to get more Layouts you need to add them

TCEFORM.tt_content.layout {  
  addItems {
    4 = my Layout 4
    5 = my Layout 5
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM