Getting parent / nested Flux CE within fluid - typo3

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.

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.

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

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)?

Related

typo3 add content element to all pages that are direct child of a certain page using typoscript

I have defined a menu content element using typoscript:
lib.share = COA
lib.share {
wrap = <div class="shareLinkBlock">|</div>
1 = TEXT
1.data = page : title
...
I would like to add this menu to colPos 2 of every page, that is direct child of a certain page.
Is there any way to achieve that?
Thanks a lot!
A solution depends on the current realization of the page.
If you use only typoscript you can replace the colPos2 rendering with a COA where your typoscript is part one and the old rendering is a second part.
Using conditions can restrict the appearance to selected page trees.
In similar ways you can realize it with FLUID.
You can insert a fluid variable, filled with your typoscript in every page.
The restriction to special page trees can be realized with conditions in typoscript or in FLUID. Also you can use different page-layouts for pages with and without this menu.
another solution would be an additional backend column which gets inherited and where you fill in your menu for those pages where the menu starts being visible. (conditions like above)
EDIT:
if you want to enhance a given FLUID variable, defined in typoscript you can word with a COA:
:
10 = FLUIDTEMPLATE
10 {
:
variables {
enhancedColumn = COA
enhancedColumn {
10 = ..old definition ...
}
}
}
:
// make sure you use the correct conditions:
[PIDinRootline = 10]
...10.variables.20 < lib.footer
[global]

How to access data from FLUIDTEMPLATE file and render that content in our desired file?

I have my package from sitepackagebuilder (v9.5.14). I no good at Typoscript. I am using the optional menu navigation file MainBefore.html (my desired file) from bootstrap_package which I put in my stpkg extension because this file is globally available in the FE alongside main menu. I try to explain my doubt in the two following examples.
First one is clear to me. usually I do things like this, (My only known typoscript way to access and render things).
Example 1:
In typoscript
lib.stdContent = FLUIDTEMPLATE
lib.stdContent {
file = EXT:sitepackagebuilder/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
In Data.html
<h4>Hello TYPO3</h4>
<h3 hidden>{mylabel}</h3>
MainBefore.html
....
<div class="from-data-file"><f:cObject typoscriptObjectPath="lib.stdContent" /></div>
....
The above example will work.
Example 2:
But this following example is my doubt.
page.10 = FLUIDTEMPLATE
page.10.variables.userInfoForChat = COA_INT
page.10.variables.userInfoForChat {
10 = FLUIDTEMPLATE
10 {
file = EXT:company/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
}
How can I access variables in Data.html and render content in MainBefore.html like example 1? Correct me If I am wrong
Both files are in same location.
First: you are doing very complicated things. normaly stacking templates inside each other is not necessary. so the main question would be: What do you intend to do?
Then we can find a simple way to do it.
I try to identify your intention:
you have a main template (main = main for this example, otherwise it is just a small part of the general page rendering) where you want to have a variable, which is filled from another template, where some variable is inserted.
Some information is missing as these would not be necessary when all values are static like in your example.
There must be something non static as you use a uncached COA_INT and the name userInfoForChat hints to something user specific, which of course is not cachable.
My question is: why do you put a complete fluid templating in the variable, when it should be enough to have only some uncached values in it and stay with just one set of fluid template. (That set already could consists of template, layout and a lot of partials)

TYPO3 use several content elements

new to TYPO3. Trying to learn.
Let's say i have about 10 content elements on my page. I will add them to the "page" list in the backend UI.
How do i actually use them via Typoscript when using fluid?
I have one content element named "logoTitle" and one content element named "content". Both in the "normal" column.
How can i access them via Typoscript?
I tried something like that:
content < styles.content.get #only get the "content" one from the normal column
logoTitle < styles.content.get #only get the "logoTitle" one from the normal column
Thanks!
In very general there are 4 default columns in TYPO3: normal, left, right, border, so you can put your elements into separate columns (let's say content into normal and logoTitle into border, then your TS should look like:
content < styles.content.get
logoTitle < styles.content.getBorder
Edit:
For more columns/mapped elements you have at least 4 possibilities:
EXT: gridelements
EXT: TemplaVoila
adding new columns into your page: http://typo3.org/documentation/snippets/sd/35/
Finally as Jost pointed in his comment in TYPO3 ver. 6+ you can use Backend Layouts for adding more columns, which are considered as a raw replacement of the old way pointed in previous point.
Personally I prefer them in this order, as first two options allows to keep the BE clean, anyway 3rd is most traditional - for rendering new columns into check colPos keyword in the docs.

TYPO3 how duplicate content in severals page

I have a TYPO3 website.
I have 4 contents in my home page which I had created with TemplaVoila (flexible content).
I want to know if there is an easy way to duplicate these contents in all the others pages.
Yes, TemplaVoila allows you to reference ContentElements with special icon, which means that you insert it on some page and then you creates a references. If "first" CE changes, all references reflect it automatically.
Optionally, if all CE's are places in one TV's column you can use TV Content Slide extension by Bernhard Kraft.
Just map that content using typoscript using the below code and use it:
lib.leftcolumncontents = COA
lib.leftcolumncontents{
5 = RECORDS
5 {
tables = tt_content
source = 26 # content element id
}
15 = RECORDS
15 {
tables = tt_content
source = 36 # content element id
}
}

TYPO3: How do I insert page content into template

I have some content that I want to appear on multiple pages of my TYPO3 site. I could just insert this into the template, but I also want that content to be editable in the Rich Text Editor.
So I had the idea of creating a hidden page, but I don't know how to insert this content into a template.
Does it require the select typoscript statement?
Also, as a follow-up question, can I add something to say, only include pages that have this page id as their immediate parent in the page hierarchy.
I didn't quite get the second question.
If you want to include some record only to pages under some other page, then this will obviously work:
[PIDinRootline = pages-uid, pages-uid, ...]
temp.foo = RECORDS
temp.foo {
tables = tt_content
source = ID # Enter the object's ID here
}
[end]
On the other hand, if you want to include all records from pages, being children of some other page, then try something like:
1 = CONTENT
1.table = tt_content
1.select {
pidInList = parent-uid
}
Don't know if I got you right though.
Dmitri.
From Include typo3 content elements on every page:
temp.foo = RECORDS
temp.foo {
tables = tt_content
source = ID # Enter the object's ID here
}
Note the ID is the content record ID, not the page ID.
But that doesn't answer the question of how to only include pages/records with a certain parent.
You can set up a hidden page and then "import" the content elements on a given page via typoscript on the pages (or the entire page tree below) as needed.
The "trick" is to use the colPos with the select-statement. With this you can even put multiple (different) content elements in one (hidden) page that show up on different pages (depending on the setting of the column they are "in".
Example:
Create a hidden (or system) page (here example-pageid = $PID_STATIC)
Create a content element on this page (text)
Edit this content element to be shown on the right column (right equals colPos=2)
Put the following typoscript into the template on which you want the content element to be shown. You can set the pid (pageId) in the constants via PID_STATIC or "hardcode" it into the typoscript.
.
lib.aditionalcontent = COA
lib.aditionalcontent {
10 = CONTENT
10 {
table = tt_content
select.where = colPos = 2
select.orderBy = sorting
select.pidInList = {$PID_STATIC}
}
Add the element lib.aditionalcontent into your template where the content should be shown. For example:
.
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/maintemplate.htm
page.10.workOnSubpart = DOCUMENT_BODY
page.10.marks.ADITIONAL_CONTENT < lib.aditionalcontent
.
Watch out, that you set the colPos according to the column that you have set the content element into, otherwise it just will not show.
You can use different columns to do this for different content that has to show up/should not show up on a particular page.
This also works with sytemfolders and non-hidden pages.
If you use TemplaVoila, this should also work although you have to switch to the listview to see and set the colum for the content element (if not hidden for this non-admin user).
To find out which colPos-number is which position of the column go to the phpMyAdmin and search for the field "colPos" in the tt_content table.