-1

In a TYPO3 mask element, I need to know the position of the item in the current column. Like any iterator you would use in a template, but on the level of the column.

I know that with the syntax {cObject}.renderObj.{maskElement}.settings.xyz I can pass in values into the mask element's fluid template. But apparently, TypoScript that goes to settings is not rendered, is that correct?

I tried this:

pageteasers < styles.content.get
pageteasers.select.where = colPos=2
pageteasers {
    renderObj.mask_teaser.settings {
        set_number = LOAD_REGISTER
        set_number {
            counter2.cObject = TEXT
            counter2.cObject.data = register:counter2
            counter2.cObject.wrap = |+1
            counter2.prioriCalc = intval
        }
        get_number = TEXT
        get_number = register:counter2
    }
}

Or simpler

pageteasers < styles.content.get
pageteasers.select.where = colPos=2
pageteasers {
    renderObj.mask_teaser.settings {
        elementId = {cObj:parentRecordNumber}
    }
}

This will output the string {cObj:parentRecordNumber}.

My questions are:

  • Is there another "road" into the mask element from TS than settings where maybe the objects are rendered?
  • How do I number the elements in my column anyway...?
Urs
  • 4,984
  • 7
  • 54
  • 116

1 Answers1

1

You should go for variables instead of settings, since those are rendered as cObjects and therefor offer you the fully blown stdWrap tool box.

https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Fluidtemplate/Index.html#variables

pageteasers < styles.content.get
pageteasers.select.where = colPos=2
pageteasers {
    renderObj.mask_teaser {
        variables {
            // count up elements
            // https://stackoverflow.com/questions/67844215/counter-for-mask-elements-in-a-typo3-column // <- Self-reference!
            elementCounter = TEXT
            elementCounter.value = {cObj:parentRecordNumber}
            elementCounter.insertData = 1
        }
    }
}
Jo Hasenau
  • 2,526
  • 1
  • 14
  • 16
  • Thanks & Good to know that „settings“ is not rendered! — But I‘m not sure the mask element will accept the variables, as I tried that first and it wouldn‘t see them. What I did was the same code as above, but with „variables“ instead of „settings“. Or does that require a different syntax? – Urs Jun 05 '21 at 16:17
  • Yeah, it’s that SO forces you to wait 7hours to accept your own answer. If you want you can add the working code to your answer and then I can accept that one with the complete result! – Urs Jun 07 '21 at 05:53
  • I'm pretty sure this works also for non-mask items, right? But how? I have a news plugin I need to feed with the same variables in the same column. But I can't figure out how to address it properly so it receives the variables... is this also via `renderObj.{element}`? Can you help me what to add there @jo-hasenau? – Urs Jul 15 '21 at 17:06
  • How about plugin.tx_news? – Jo Hasenau Jul 15 '21 at 17:23
  • Do you mean `pageteasers.renderObj.plugin.tx_news.variables.myVar = 1`? That doesn't seem to work – Urs Jul 15 '21 at 18:57
  • Sure! It's here: https://stackoverflow.com/questions/68403392/ – Urs Jul 18 '21 at 09:12