Adding the page content to a fluid template - typo3

I'm new to TYPO3 and Fluid and trying to display the page content using a Fluid template similar to the following one:
<div id="content">
<f:format.html>{content}</f:format.html>
</div>
The page data is entered via the backend using a two-column layout (colPos=0, colPos=1).
I am now trying to display the content of the first column (colPos=0) inside the div.
At the moment, my TYPO-Script looks like the following:
page = PAGE
page {
# ...
5 = FLUIDTEMPLATE
5 {
file = fileadmin/templates/default.html
# ...
variables {
pageTitle = TEXT
pageTitle.data = page:title
content = CONTENT
content {
table = tt_content
select {
where=colPos=0
}
renderObj = COA
renderObj {
10 = TEXT
10.field = bodytext
}
}
}
}
It works this way, but I cannot get rid of the feeling that my 5.variables.content is way too complicated.
I saw some solutions using content < styles.content.get as an alternative but using this causes my resulting div to be empty.
Are there any more elegant ways (i.e. shorter in this context) to achieve what I am doing?

On your question which approach is more elegant
(I don't use fluid, but I think it's general Typoscript):
If you want to use css_styled_content, but with more flexibility and transparence than the shortcuts "get", "getLeft" etc., use this:
content < styles.content.get
content.select.where = colPos = 0
No need to specify content = CONTENT in that case.
In the way you wrote it above, you would probably need to add:
10.parseFunc = < lib.parseFunc_RTE
to your renderObj, as else, automatically linked e-Mail addresses etc. won't be rendered in the content.
If you want full control over the markup, your original approach using the CONTENT object is superior to css_styled_content. But you will have to cover each field the editors are supposed to use.
I always use this article: http://www.typo3wizard.com/en/articles/explaining-the-content-object.html
With css_styled_content on the other hand, you get parsing for all fields for free - but also you get all the markup it will write for you.
It might be helpful to look at csc's static template in /typo3/sysext/css_styled_content/static/setup.txt to see what it does.

i dont use fluid, just plain TS for my projects, but i hope ill help.
In backend the cols are like this if u have not "touched" em:
| col1(Left) | col0(Normal) | col2(Right) | col3(Border) |
What i do is this for "normal" layout:
page.10 = TEMPLATE
page.10 {
subparts{
LEFT-CONTENT < styles.content.getLeft
CONTENT < styles.content.get
RIGHT-CONTENT < styles.content.getRight
}
marks {
DESCRIPTION < styles.content.getBorder
}
If u need something more u can use something like this to generate some content that is not on that page and can use it to display it on all pages.
subparts{
LEFT-CONTENT < styles.content.getLeft
LEFT-CONTENT {
select.pidInList = 50
select.where = colPos=0
select.orderBy = sorting
wrap = <div class="col100">|</div>
}

page.5.variables.content < styles.content.get
Of course you must have the CSS styled content extension installed (default) and the static template "CSS Styled content" included in your TypoScript Template (Tab: Includes).

Alternative solution: https://fluidtypo3.org/viewhelpers/vhs/development/Content/RenderViewHelper.html (along with get and random get/render counterparts).

Related

TYPO3 render Event from typoscript and Fluid template

In TYPO3 10.4.8 I have the following page tree:
root
1level: Events
2level: Event A, Event B, Event C, ... and so ...
What I want to do in page Events is to render all subpages title, using FLUIDTEMPLATE.
So in the template of page Events I wrote
lib.EventContent = COA
lib.EventContent {
10 = COA
10{
table = pages
select {
orderBy = sorting
pidInList = this
}
}
}
and in the layout file
<f:for each="lib.EventContent" as="event" >
<p>event: {event.title}</p>
</f:for>
This doesn't work. Typo give me this error:
The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3Fluid\Fluid\ViewHelpers\ForViewHelper".
In addition, I also tried to change COA with CONTENT, in all possible combination (COA-CONTENT / CONTENT-COA / CONTENT-CONTENT)
What's wrong? is something that I cannot do?
Thanks all
The TypoScript should look something like this:
lib.EventContent = CONTENT
lib.EventContent {
table = pages
select {
orderBy = sorting
pidInList = this
}
}
But there is a much easier solution. TYPO3 already brings a content element "Subpages" which renders a menu of all subpages of a selected page:
This is done via Fluid Styled Content and TypoScript. Please check this file for details:
typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/MenuSubpages.typoscript
A solution for you might look like this (untested):
lib.EventContent < tt_content.menu_subpages
lib.EventContent {
dataProcessing {
10 {
special >
}
}
}
It's also a good idea to have a look in all the TypoScript files in the Fluid Styled Content extension to get more inspiration.

TYPO3: How to get only parts of a record?

I want to built a content element with fields for text and images (I'm using the Mask extension for this) and use parts of the contents of it on further pages, for example as teasers.
Is it basically possible to put out only parts of a specific record, e.g. only the text and can an anybody give me a hint or an example how to?
Thank you for your help!
Michael
What you are rendering is your selection. In mask you already use only a subselection of all available fields in a tt_content record. It s very complicated for an editor if you use fields in your rendering, that can't be edited.
Assume you have CE (content element) of type A with some fields which all are filled with data, then you change the type to B which has other fields. As you have not emptied the fields from type A you still can access them and render it in the frontend.
if you want to render teaser you use only those fields you think what gives you the teaser information.
In general records are handled complete.
you can define your own viewhelper which provide you with restricted data or you use typoscript where you do the rendering in typoscript and you have no access to individual fields.
e.g. you could use a CONTENT object, selecting data from CEs in another page:
temp.teaser = CONTENT
temp.teaser {
table = tt_content
select {
// assuming context of a page, like in a menu
pidInList.field = uid
orderBy = sorting
max = 1
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
10.wrap = <div class="head">|</div>
20 = TEXT
20.field = bodytext
20.wrap = <div class="content">|</div>
20.crop = 100 | ... | 1
wrap = <div class="teaser">|</div>
}
}

Append extension output to main content via typoscript

It might be a simple solution to that but I am not able to figure it out.
I implement a typo3 6.2.12 website using the bootstrap_package extension. There I have a page with child pages within the page tree. On each child page a comment function should be attached at the end of the main page content. For the comment functionality I use the pw_comments extension, as it is very flexible.
The pw_comments manual shows a possible the integration as follows:
lib.content = COA
lib.content {
10 < styles.content.get
# List comments
20 < lib.pwCommentsIndex
# Write new comment
30 < lib.pwCommentsNew
}
Actually very simple and straightforward.
The bootstrap package extension handles the content as follows (inside base.ts):
lib.dynamicContent = COA
lib.dynamicContent {
5 = LOAD_REGISTER
5 {
colPos.cObject = TEXT
colPos.cObject {
field = colPos
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value.current = 1
ifEmpty = 0
}
}
pageUid.cObject = TEXT
pageUid.cObject {
field = pageUid
ifEmpty.data = TSFE:id
}
}
20 < styles.content.get
20.select.where = colPos={register:colPos}
20.select.where.insertData = 1
20.select.pidInList.data = register:pageUid
90 = RESTORE_REGISTER
}
lib.dynamicContentSlide =< lib.dynamicContent
lib.dynamicContentSlide.20.slide = -1
And at that point I have no clue how to integrate pw_comments. In the setup of the plugin I tried this:
[PIDupinRootline = 54]
lib.dynamicContent = COA
lib.dynamicContent {
# List comments
30 < lib.pwCommentsIndex
# Write new comment
31 < lib.pwCommentsNew
}
[end]
The goal of the above is: Attach pw_comments to the main column output to each child page of parent page with uid 54.
Actually it is working but due to the inheritance with lib.dynamicContentSlide =< lib.dynamicContent the comments get also attached each of the 3 footer columns which is not desired behavior.
I could use the plugin extension which is available for pw_comments but that would mean that the editor has always to add that plugin to new child pages when creating them.
I could "hack" the fluid content template files and add a <f:cObject /> tag and call the plugin lib, but I think that solution is odd and .. well .. a hack.
So is there any way how I could attach that plugin to these child pages in a typo script way? I guess it is just a lack of syntax knowledge and yes, typo3 is not my every day job.
Hope anybody can give me a hand on this issue. Thanks so much in advance!
You simple need to replace the reference by a real copy before you add your TypoScript.
lib.dynamicContentSlide < lib.dynamicContent
# your TS goes here
Just repeat all lines with an reference to lib.dynamicContent with a copy operator instead, before you add your modifications to the actual content definition.

get page title in styles.content.get

I am getting the content of a certain page and output it on another page in typoscript. what i would like to do is to get the page title and output it above the content.
This is my code for getting the page content:
lib.Section1 = CONTENT
lib.Section1 < styles.content.get
lib.Section1 {
select.languageField=sys_language_uid
select.where = colPos=0
select.pidInList = 19
}
For printing the page title i'm thinking of something like this:
lib.Section1.wrap = <div class="title">{page_title}</div>|
but i haven't been able to find the right method. Googling didn't help as the most methods i found there involved an hmenu or tmenu, which is not very practical in my case because i only need the content of a particular page. Maybe there is someone who can help.
You should indeed use a HMENU, since other methods (using CONTENT or similar) will run into problems with translations and selecting the right page.
Here is a simple HMENU:
lib.pageTitle = HMENU
lib.pageTitle {
special = list
special.value = 19
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
wrapItemAndSub = <h1>|</h1>
}
}
}
Have you tried this?
lib.Section1.dataWrap = <div class="title">{page:title}</div>|
First of all i think you need to use dataWrap to insert global Values (variables). And after that you can access some global data like page title i think.

Typo3: How to use title of header_link field as link text?

using Typo3 6.1, I'd like to be able to add a link with an editable caption to the end of each content element, linking to some related page. My approach was to (mis)use the header_link field for that. I removed the typolink from the headline and added the link after the content.
# something like:
20.text.20.append {
if.isTrue.field = header_link
value = more...
typolink.parameter.field = header_link
wrap = <div class="button">|</div>
}
To be able to use different captions for each link (instead of "more..."), I hoped to use the title property of the typolink since it can easily be set in the backend. Is this possible? Or is there a more reasonable way to achieve this?
The most straightforward way would probably be adding a new link field and a title field for that link by building a custom extension just for that purpose (adding the fields to BE and Database). Then editors can fill in these fields in the same tab and you can access them with typoscript.
You can use COA with new Object
100.value = more
100.wrap = <div class="button">|</div>
100.typolink ...
or use wrapper existing element
stdWrap.typolink {
wrap = <div class="linkwrap">|</div>
parameter.insertData = 1
parameter = {field:header_link}
ATagParams = class="headerLink"
ATagBeforeWrap = 1
}