Is it possible to get the parent CE type/name within a nested CE? I have a Custom Flux Grid CE with two columns, inside the columns you can place another CE. Now I would like to detect if the child is inside the grid, if yes do this and that.
-
1what construction or extension do you use to stack CEs into each other? you might add tags regarding extensions and versions. – Bernd Wilke πφ Feb 18 '19 at 11:43
-
"Custom Grid CE" – Alex Kellner Feb 18 '19 at 12:14
3 Answers
Regardless of the technology used to store the relation between parent and child, you could always go for the FLUIDTEMPLATE parameter dataProcessing
.
Either create a variable children
or parent
via a DatabaseQueryProcessor like that
tt_content.mycontent.20 = FLUIDTEMPLATE
tt_content.mycontent.20 {
file = EXT:site_default/Resources/Private/Templates/ContentObjects/MyContent.html
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
dataProcessing.10 {
# regular if syntax
if.isTrue.field = records
# the table name from which the data is fetched from
# + stdWrap
table = tt_address
# All properties from .select can be used directly
# + stdWrap
colPos = 1
pidInList = 13,14
# The target variable to be handed to the ContentObject again, can
# be used in Fluid e.g. to iterate over the objects. defaults to
# "records" when not defined
# + stdWrap
as = myrecords
# The fetched records can also be processed by DataProcessors.
# All configured processors are applied to every row of the result.
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
}
You can use all the parameters of select
for that DataProcessor and each of them can be modified using stdWrap properties. https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Select.html
Just make sure to replace as = myrecords
with the desired variable name and then access this variable directly from within your Fluid template. You can use <f:debug>{_all}</f:debug>
to get an overview of the available variables.
Taken from these docs https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html#dataprocessing
Additionally you might want to take a look at this video https://www.twitch.tv/videos/380759921 to get an idea what dataProcessing is about.

- 2,526
- 1
- 14
- 16
-
Ok I think I missed a small detail, I use flux for my CEs. Don't know if your method (which I honestly didn't understood completly) works in this case. – Paul Feb 18 '19 at 16:38
-
You could render Flux content with a FLUIDTEMPLATE cObject too, but in this case it might be easier to transfer variables directly, since the information is already available without using a data processor: https://stackoverflow.com/questions/24690804/how-the-get-the-parent-element-of-a-fce-in-fluid-powered-typo3 – Jo Hasenau Feb 18 '19 at 20:15
Since the FLUIDTEMPLATE approach is a universal one, while the question might be closer related to Flux, here is a Flux specific way to hand over information to child records:
https://fluidtypo3.org/viewhelpers/flux/master/Content/RenderViewHelper.html
<flux:content.render
area="NULL"
limit="123"
offset="123"
order="'sorting'"
sortDirection="'ASC'"
as="NULL"
loadRegister="{foo: 'bar'}"
render="1"
>
<!-- tag content - may be ignored! -->
</flux:content.render>
Just fill in some additional information to the loadRegister
named foo
to make it available via the getText method register:foo
within the child rendering process.
loadRegister="{parentRecordType: '2'}"
and within your child record rendering use
10 = TEXT
10.dataWrap = My parent record is of type {register:parentRecordType}
Same goes for if conditions or switch objects based on the registered information. And of course for Fluid based rendering of child records too.
Just use <f:debug>_all</f:debug>
to get an overview of available registers and data.
https://docs.typo3.org/typo3cms/TyposcriptReference/DataTypes/Index.html#register

- 2,526
- 1
- 14
- 16
Yes, everything is possible with TYPO3 and in a lot of ways. How are the content elements nested? From parent to children (templavoila) or from children to parent (gridelements)?

- 1,263
- 6
- 11
-
-
Yes, sorry, should be a comment because feedback is needed to answer the question. – Alex Kellner Feb 18 '19 at 12:14