0

In TYPO3 7 LTS with ext:mask, I would like to pass a value from my page template into the FLUIDTEMPLATE that is rendered via the mask extension.

An example for what I'm trying to achieve:

The content element has content that describes a car: A Volvo, 4WD...

In the page template, I want to display that "car" in different colors. So the page template would be able to command: "get the first car, and show it in green. Then the second car and show it in yellow". (and no, it's got nothing to do with css..)

If this has to be done once onan entire page, I can use

`tt_content.default.mask_car.settings.color = green`

Or (for the record) if the purpose of that variable would be to modify the presentation, I could use:

`tt_content.default.mask_car.settings.file = path/to/Mask/Content/Templates/car_green.html`

But if there are several instances of the same content element on the page, that approach is no good.

How to pass different values into different instances of the same CE on a page?

r4fx
  • 652
  • 5
  • 12
Urs
  • 4,984
  • 7
  • 54
  • 116

3 Answers3

4

you could add following TypoScript:

lib.set_register = LOAD_REGISTER
lib.set_register.color = TEXT
lib.set_register.color.current = 1

lib.get_register.color = TEXT
lib.get_register.color.data = register:color

lib.mask_car < styles.content.get
lib.mask_car.select.where = colPos=123

And within your page template you set the color with Fluid

<f:cObject typoscriptObjectPath="lib.set_register.color" data="green"/>

Get your content elements with Fluid

<f:cObject typoscriptObjectPath="lib.mask_car"/>

And switch the content element's out put within your mask template with Fluid

<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.get_register.color')} == 'green'">
    <f:then>
        green
    </f:then>
    <f:else>
        not green
    </f:else>
</f:if>

I hope this helps you to solve your problem.

2

I had a similar problem: A collection of mask content elements; two different renderings of the same element on the same page:

  • One random mask-ce rendered as teaser, linking to the detail on the bottom of the page

  • A list of all mask ce's rendered as list-items (detail)

    My solution:

Rendering of the random teaser:

lib.qa_random_teaser_community < styles.content.get
lib.qa_random_teaser_community.select{
  where = colPos=12
  pidInList = {$pidCommunityQAStorage}
  max = 1
  orderBy = rand()
}

Rendering of the detail list:

lib.qa_list_community < styles.content.get
lib.qa_list_community{
  renderObj < tt_content
  renderObj.default.mask_qa_community.settings.renderListItems = 1
  select {
    where = colPos=12
    pidInList = {$pidCommunityQAStorage}
  }
}

I copy the tt_content to renderObj, then I can modify it, adding a dedicated setting for the mask element just for this content rendering:

renderObj.default.mask_qa_community.settings.renderListItems = 1

In the mask template, I just have to check for the setting and trigger the appropriate rendering:

<f:if condition="{settings.renderListItems}">
  <f:then>
    <f:render section="qa-detail" arguments="{data:data}"/>
  </f:then>
  <f:else>
    <f:render section="qa-teaser" arguments="{data:data}"/>
  </f:else>
</f:if>

Another approach would be to select a dedicated fluid-template instead of just feeding a setting:

renderObj.default.mask_qa_community.settings.file = .......

In Mask 3.0.1 with TYPO3 8...

renderObj.mask_qa_community.settings.file = .......

Hope it's useful for someone else.

Community
  • 1
  • 1
thismaechler
  • 201
  • 2
  • 3
0

I'm revisiting this question, in TYPO3 9 with mask 4.x, this works:

lib.my_content_element {
  renderObj.mask_content_text.settings.test = 123
}
Urs
  • 4,984
  • 7
  • 54
  • 116
  • I don't know how to switch the template file completely. Not sure if it still works. – Urs May 26 '19 at 19:49