Search code examples
typo3typo3-7.6.xtsconfig

How to use string values for layout field of content elements?


When using CASE, (such as for layout or frame options) I would like to use words instead of numbers so that it's easier to see what each item is for.

According to the documentation this should work as long as I avoid the words that have special meaning like “if”, “setCurrent”, “key”, and “stdWrap” and “default”

However when I use any of these values in TS Config:

TCEFORM.tt_content.layout.addItems {
    banner-home = Banner Home
    banner_home = Banner Home
    bannerHome = Banner Home
    bannerhome = Banner Home
}

the content element will not save it and the layout dropdown reverts to Default.


Solution

  • Since the layout field of tt_content is

    layout int(11) unsigned DEFAULT '0' NOT NULL
    

    you need to change the field type first to be able to store non numeric values.

    Changes to the database structure can be applied through ext_tables.sql files within your own extension. Make sure your extension is loaded after the existing extension, which is defining int(11) for this field. Add a depends entry inside ext_emconf.php to do so.

    See: