0

The questions and answers here already explain how to use constants in plugins and / or constants in templates based on FLUIDTEMPLATE.

What I would like to do is something like in this answer: https://stackoverflow.com/a/41956201/2444812

but not have to assign each setting individually but put them in a container and assign that as variable. For plugins there is a mechanism to be able to access the settings easily, via {settings} e.g. instead of doing:

10 = FLUIDTEMPLATE
10 {

    variables {
        setting1 = TEXT
        setting2.value = {$constant1}
        setting2 = TEXT
        setting2.value = {$constant2}
    }

I would like to do something (similar to):

lib.tx_myext.settings {
    setting1 = {$plugin.tx_myext.settings.setting1}  
    setting2 = {$plugin.tx_myext.settings.setting1}  
}

10 = FLUIDTEMPLATE
    10 {

        variables {
            settings < lib.tx_myext.settings
        }

And then use this in Fluid like {settings.setting1}.

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
  • Maybe a DataProcessor like this one can help you: https://github.com/portrino/px_semantic/blob/master/Classes/Processor/TypoScriptProcessor.php – Julian Hofmann Nov 06 '20 at 10:54
  • little bit late to the party, but in similar need I ended up with custom ViewHelper(s) to fetch settings and/or conditionally display template/layout/partial's elements basing on plugins settings. Works quite cool, if somebody needs someyhing like this I can write a sample. (contact via my profile's e-mail) – biesior May 11 '23 at 10:53

1 Answers1

1

In this case lib.tx_myext.settings resolves to a simple map of plain values so you can just copy that into settings instead:

10 = FLUIDTEMPLATE
10 {
  settings < lib.tx_myext.settings
}

If you have existing settings you can add them afterwards:

10 = FLUIDTEMPLATE
10 {
  settings < lib.tx_myext.settings
  settings {
    custom1 = ...
  }
}
Mathias Brodala
  • 5,905
  • 13
  • 30
  • For some reason this did not work for me. But I will check again and try to find out what the problem is exactly. (sometimes it's just a simple typo ....) – Sybille Peters Nov 06 '20 at 10:57