Typoscript : Separate Content Header from Body Text - html

YES, I have been looking for answers and couldn't find anything that worked or did what I wanted it to do. Neither in German nor in English, so this is my last resort:
I included a Javascript on the site I am programming. The usual JQuery Content Slider.
( http://jquery.andreaseberhard.de/toggleElements/ ).
I included it into a Typo3 Site. I created a stdWrap so that each entry in the column "Normal" ends up in one of the sliders. All very nice so far.
The Documentation says it uses:
<div class="toggler-c" title="Example 1">
to declare each toggler.
My wrap looks like this:
10.marks.CONTENT = COA
10.marks.CONTENT.10 = CONTENT
10.marks.CONTENT.10 {
renderObj.stdWrap.wrap = <div class="toggler-c" title="" >|</div>
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
}
The Problem is that this will write everything including the header of the entry into the toggler and doesnt use the header as the visible title.
I dont know how to grab the Header of the content element to write it into the "title"-attibute of the wrap.
Thank you very much for your suggestions!
Halest
EDIT:
I have been trying different things:
How far is this off?
10.marks.CONTENT = COA
10.marks.CONTENT.10 = CONTENT
10.marks.CONTENT.10 {
renderObj < tt_content
renderObj.stdWrap.cObject {
key = CType
header = |
default = <div class="toggler-c" title="|" ></div>
bodytext = |
default = <div class="toggler-c" title="">|</div>
}
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
}
(This doesnt show anything but I wonder if it is THAT wrong.

Well I got it to work, thanks anyway I guess?!
10.marks.CONTENT = COA
10.marks.CONTENT.10 = CONTENT
10.marks.CONTENT.10 {
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
renderObj < tt_content
renderObj = COA
renderObj {
10 = TEXT
10.field = header
10.wrap = title="|"
20 = TEXT
20.field = bodytext
20.wrap = >|
wrap = <div class="toggler-c" |</div>
}
}

My version according to the above posts and some searching on the web:
I've put this in the marks part of the template:
HEADING = CONTENT
HEADING{
# find current content from the tt_content table
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
# render the header as simple text
renderObj < tt_content
renderObj = TEXT
renderObj.field = header
}
CONTENT = CONTENT
CONTENT{
# same goes here
table = tt_content
select.orderBy = sorting
select.where = colPos = 0
# trying to render the bodytext as an HTML content
renderObj < tt_content
renderObj = TEXT
renderObj.field = bodytext
renderObj.parseFunc < lib.parseFunc_RTE # Remove this line, if you want to remove the &ltp class="bodytext"> markups
}

You properly want to have a look at the tt_content part in the TypoScript Object Browser.
What you needs is as CASE with key = CType and a special configuration for header (empty wrap) and default with your wrap for all other elements.
renderObj.stdWrap.cObject = CASE
renderObj.stdWrap.cObject {
key = CType
header = |
default = <div class="toggler-c" title="" >|</div>
}
(Untested).

Related

Rendering content element by Uid

I'm trying to render a content element only by having it's Uid.
It's supposed to be the login form of fe_login placed directly into a navigation Overlay.
I tried saving the element into a variable by using CONTENT. It did not work, obviously.
But I'm not even sure if I used used the correct syntax.
page.10.variables.contentLogin = CONTENT
page.10.variables.contentLogin {
table = tt_content
select.where {
uidInList = 32
pidInList = 0
}
}
And the same for lib.loginContent.
Added both respectively with
{contentLogin -> f:format.raw()}
<f:cObject typoscriptObjectPath="lib.loginContent"/>
But this only renders the object I already have on this page and not the element I am looking for globally.
EDIT: I found the solution. See my own answer.
I found the solution. The problem in my code is the select.where statement.
The working code is:
lib.loginContent = CONTENT
lib.loginContent {
table = tt_content
select {
uidInList.field = myUid
pidInList = 0
}
}
and in HTML
<f:cObject typoscriptObjectPath="lib.loginContent" data="{myUid: 32}"/>
The change I made was to just delete the ".where" from the select.
After checking the Doc again and again I finally realized my mistake. I hope other people will find this question and answer useful as I did not find anything on the internet that could help me with the problem.
Code for static content element:
lib.foo = CONTENT
lib.foo {
#tt_content is the default table. I just like to write down where Im looking for it
table = tt_content
select {
uidInList.field = Your ContentElement ID goes here!
pidInList = 0
}
}
<f:cObject typoscriptObjectPath="lib.loginContent">
That's it. Enjoy!
The f:cObject-viewhelper has a data-attribute for passing any data to the called TypoScript-object. The passed data is accessible as fields in TypoScript:
The Fluid part:
<f:cObject typoscriptObjectPath="lib.loginContent" data="{myUid: 123}"/>
And in TypoScript:
lib.loginContent = CONTENT
lib.loginContent {
table = tt_content
select.where {
uidInList.field = myUid
pidInList = 0
}
}

Reading TYPOscript fe_users does not work within a COA

I have just the following problem, I would like to spend via TYPOScript a specific FE_user in the template, only this does not work, is there a restiktives SQL statement or I use here what wrong? Maybe it's the nesting?
Here is the code:
lib.contactPasswords = COA
lib.contactPasswords.10 = TEXT
lib.contactPasswords.10.value (
<p>User: Safari</p>
)
lib.contactPasswords.20 = CONTENT
lib.contactPasswords.20 {
table = fe_users
select {
max = 1
pidInList = 173
andWhere = username = 'Safari'
}
renderObj = COA
renderObj
{
10 = TEXT
10.field = username
wrap =|<br / >
}
}
lib.contactPasswords.20.wrap = <div>User: |</div>
And the output is the same like:
<p>User: Safari</p>
<div>User:</div>
Desired result:
<p>User: Safari</p>
<div>User: Safari</div>
Can someone explain to me where the mistake is, why the content remains empty?
More Information:
TYPO3 Version: 8.7.19
Using like: <f:cObject typoscriptObjectPath="lib.contactPasswords" /> in Fluid Template
And yes: The User "Safari" exist in the database :)
Are you sure the username is Safari? Usernames are usually all lowercase in TYPO3. If you added it through the backend it will be cast to lowercase. So it would be safari.
You should not have an enter between cObject and {. It should be cObject {
Also andWhere is deprecated since TYPO3 7.1 and removed in TYPO3 8.7. You should use where instead.
For me, this works:
lib.contactPasswords.20 = CONTENT
lib.contactPasswords.20 {
table = fe_users
select {
max = 1
pidInList = 173
where = username = 'safari'
}
renderObj = COA
renderObj {
10 = TEXT
10.field = username
wrap = |<br / >
}
}
'andWhere' reqires, that you also used 'where' in your statement.
But avoid using 'andWhere' since it is deprecated. See https://docs.typo3.org/typo3cms/extensions/core/Changelog/7.1/Deprecation-25112-andWhere.html

Read DB entries dynamically in TypoScript

I have the following setup for my Typo3 installation:
TypoScript:
lib.responsiveImage = IMAGE
lib.responsiveImage {
default = IMAGE
default{
file {
import.current = 1
treatIdAsReference = 1
}
altText.data = DB:sys_file_reference:26:alternative
titleText.data = current
}
}
Which produces the following output Tag (unneccessary content deleted; important is the alt and the title tag):
<img class="img-responsive" srcset="XY.jpg" alt="AltText" title="26" sizes="(min-width: 1200px) 1100px">
As you can see, current delivers the correct uid of "26". The database query via DB:sys_file_reference:26:alternative delivers the correct "AltText".
However -> How could i achieve that dynamically?
I tried something like this
DB:sys_file_reference:{current}:alternative
but this doesnt worked. current should be the uid of an FileReference
(Also altText.data = file:current:alternative gives me an Error: No File Object)
Maybe the use of the FILES element is safer:
lib.responsiveImage = FILES
lib.repsonsiveImage {
references.current = 1
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
altText.data = file:current:alternative
titleText.data = file:current:title
emptyTitleHandling = useAlt
}
}
Luckily i found a solution:
default = IMAGE
default{
file {
import.current = 1
treatIdAsReference = 1
}
sourceCollection < tt_content.image.20.1.sourceCollection
layout < tt_content.image.20.1.layout
layoutKey = srcset
altText.data.dataWrap = DB:sys_file_reference:{current}:alternative
altText.wrap = |
}
If you use dataWrap the {current}works as expected!

TYPO3 7.6: bodytext html output with typoscript?

After I upgraded TYPO3 from 6.2.9 to 7.6.15 the bodytextfield isn't parsed as HTML anymore. My typoscript creates XML output and I need the bodytext as HTML output.
...
10 = CONTENT
10 {
table = tt_content
select {
where = colPos=0
orderBy = sorting
selectFields = image,header,bodytext
languageField = sys_language_uid
}
wrap = <items>|</items>
renderObj = COA
renderObj {
wrap = <item>|</item>
10 = TEXT
10 {
wrap = <title>|</title>
field=header
}
20 = TEXT
20 {
wrap = <text><![CDATA[ | ]]></text>
field = bodytext
parseFunc = < lib.parseFunc_RTE
}
...
I think the lib.parseFunc_RTE is not working anymore?
Using =< you are referencing to lib.parseFunc_RTE. If it gets deleted somewhere in your Typoscript, the reference will be lost. Check out the Template -> Typoscript if lib.parseFunc_RTE is still present in your Typoscript.
You also can try to not reference it by just copying it
parseFunc < lib.parseFunc_RTE

Adding of Generic Markers to tt_news - Database related

I am trying to write a custom output to extend the tt_news-Extension. I have suceeded so far as I have successfully written:
My own extension (via the help of extension builder)
Found a method to output some of my data via GENERIC Markers and TypoScript
What I want to do is:
Read Data from a MySQL Table (from my extensions preferably)
Compare data with a tt_news Column (Column contains VARCHAR "1,2,3,4")
Look for a certain UID (WHERE tt_news.txy7... CONTAINS uid )
Only output the objects found in the list.
Now I know I should probably build a relational database in the end, containing uid, fahrzeug.uid, tt_news.uid , but I'm really trying to figure out a way to output stuff first.
I think I have a basic thinking mistake in there, but I really need to take a break, since im working nearly 6 hours on this now.
Maybe someone could provide me with some directions?
# Output via Generic Markers
temp.fahrzeuge = CONTENT
temp.fahrzeuge {
table = tx_y7fahrzeugdatenbank_domain_model_fahrzeug
wrap = <div class="tx_y7fahrzeuge_ausgabe">|</div>
select {
selectFields = uid,name,beschreibung
# where = tt_news.tx_y7fahrzeugdatenbank_participate CONTAINS uid
}
renderObj = COA
renderObj {
10 = TEXT
10.wrap = <span class="fzname">|</span>
10.field = name
20 = TEXT
20.wrap = <span class="fzdesc">|</span>
20.field = beschreibung
}
}
plugin.tt_news.genericmarkers {
fzparticipate = COA
fzparticipate {
10 = TEXT
10.value = <h2>Fahrzeuge</h2>
20 = CONTENT
20 < temp.fahrzeuge.renderObj
}
#currentnews = plugin.tt_news.currentUid
}
1) add the whole template to your COA not only the renderObj:
fzparticipate = COA
fzparticipate {
10 = TEXT
10.value = <h2>Fahrzeuge</h2>
20 < temp.fahrzeuge
}
2) make sure you have a pid set for the objects you are selecting and that you in some way set the pidInList option within the select. The result will be empty if you don't!:
select {
#set your pid here
pidInList = 35
# selected fields
selectFields=uid
where = 1=1
}
3) You can add where-clauses in 2 ways: Where & andWhere
3.1) andWhere has a cObject which you can set
table = tx_myTable_mapping
select {
#Do not forget the pid!
pidInList = {$plugin.myPlugin.pid}
#did you know that you can use distinct here?
selectFields=DISTINCT(name)
#you can use a COA here as well, for more complex clauses
andWhere.cObject = TEXT
andWhere.cObject {
#This 3 lines come in handy to prevent SQLInjections
#by fully quoting the GET/POST variable
data = GP:myPostVariable
#tell the system for which table it should do the quoting
fullQuoteStr = tx_myTable_mapping
wrap = myTablefield=|
}
}
3.2) where supports data and wrap options
table = tx_myTable_mapping
select {
#you can do joins as well:
join = fe_users on tx_myTable_mapping.fe_user = fe_users.uid
#again with the pageId
pidInList = {$plugin.myPlugin.pid}
selectFields=tx_myTable_mapping.name as MyLabel
#you can set the where in a static way like you did
#or you use the data and wrap options
where.data = TSFE:fe_user|user|uid
where.wrap = (fe_users.uid = | )
}