Search code examples
arrayscontent-management-systemtypo3typoscriptassociated-object

Using arrays in typoscript


I'm quite new to typoscript and I want to use an array to associate a subject to an email adress like this

email_mapper {
   general = [email protected]
   specific = [email protected]
}

to_mail = email_mapper[GP:formhandler|subject]

how can I do something like that in typoscript? Is it possible at all?


Solution

  • You can do that using the CASE content object. It would look somehow like this:

    to_mail = CASE
    to_mail {
        key.data = GP:formhandler|subject
    
        general = TEXT
        general.value = [email protected]
    
        specific = TEXT
        specific.value = [email protected]
    
        default = TEXT
        default.value = [email protected]
    }
    

    I haven't tested the above code, but something along these lines will work.