0
votes

I have a simple back-end module, where you can switch between or create new "themes" . For the sake of simplicity, let's say that the model contains only a logo and a color code. In my typoscript setup I'm using the following code to get the items from the DB:

temp.theme= CONTENT
temp.theme{
          select{
                ...
          }
          renderObj = COA
          renderObj {
                    #theme color
                    10 = TEXT
                    10.field = color
                    ...
                    #theme logo
                    40 = FILES
                    40{
                        references {
                              ...
                        }
                        renderObj = IMAGE
                        renderObj {
                              wrap = <div class="logo">|</div>
                              file.import.data = file:current:originalUid
                        }   
                    }
          }
}

How can i split this object into variables? This won't work, but i guess it is a good representation of what i'm trying to achieve:

lib.logo = COA
lib.logo < temp.theme.renderObj.40

Also I want to set the color as following (obviously this won't work either):

page.cssInline.1010 < temp.theme.renderObj.10

Is there a better way to achieve what I'm trying to do? What is working so far for me is to copy this object, then unset what i'm not using:

temp.logo = COA
temp.logo{
          10 < temp.theme
          10.renderObj.10 >
          ...
          #10.renderObj.40 >
          ...
}

I'm sure that there is a simpler way, but i couldn't find it.

1
Can you explain what you want to output on the page? - Paul Beck
yes, for example, i would like to render the logo like this: <f:cObject typoscriptObjectPath="lib.logo" /> While it is working this way, I would like to know if there is a more elegant solution to my problem, where i can assign the logo directly like this: lib.logo < temp.theme.renderObj.40 - csba
If your PAGE object is using FLUIDTEMPLATE to create the page, you can assign "variables" to your Fluid Template: docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/… - Paul Beck
I did end up using this method, but my main problem would be "splitting" the [temp.theme] into separate objects. If i pass it as it is, it will be just one messy object. Maybe I don't understand what you are saying, I'm a beginner developer unfortunately. - csba
page.10.variables{ color = TEXT color < temp.color } - csba

1 Answers

1
votes

You must read more about the operators and the cObjects of Typocript.

lib.logo = COA
lib.logo < temp.theme.renderObj.40

This makes lib.logo become a COA cObject and then you copy only the renderObj of temp.theme inside it. But the renderObj is useless without the CONTENT Object it belongs to. So change it to

lib.logo < temp.theme

and it will copy the whole object to it. You don't have to declare it as a COA before. Maybe you don't even need a temp. object - you can make the whole lib.logo to become the CONTENT object.

The same applies to page.cssInline.1010 - you cannot only copy the renderObj. Copy a whole object to it or make it directly become a CONTENT object:

page.cssInline.1010 = CONTENT
page.cssInline.1010 {
  select{
    ...
  }
  renderObj = TEXT
  renderObj {
   field = color       
  }
}

The only way of storing some temp results of an renderObj is using LOAD_REGISTER objects: https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/LoadRegister/Index.html?highlight=load_register

All cObjects docs: https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Index.html Operators: