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
Related
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
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!
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 = | )
}
I have a Template in TYPO3 that i want to use to some pages, in here i have a DIV.
Is it possible depending on the page UID, to changes the DIV ID. its the only div thats changes content/image, and im looking to put this DIV inside my main.html template.
so if
UID = 2 <div id="topbanner_about"></div>
UID = 3 <div id="topbanner_drills"></div>
and so on....
Can i do this, and can i do it in TS (Typo Script) or how can i do this, so i dont need to make 5 templates.
You can do this by inserting a marker in your template. It would look somehow like this:
In the template:
[...]
<div id="topbanner_###ID_SUFFIX###"></div>
[...]
In the TypoScript, where the template is inserted:
10 = TEMPLATE
10 {
template = FILE
template.file = fileadmin/main.html
marks {
ID_SUFFIX = TEXT
ID_SUFFIX {
insertData = 1
# This makes sure that the output is valid and prevents XSS attacks
htmlSpecialChars = 1
value = {page:uid} # Use this to insert the page ID or
value = {page:subtitle} # Use to insert subtitle of page
... # Same works for other fields of the page record.
}
}
}
If the fields provided by default pages are not enough, you could add another field to the page records. The best way to do that would be to build an extension that does it.
I found a better solution, if i use ressource and add an image and on the next page do the same just with another images, then in my main TS i add this code.
lib.imageElement = FILES
lib.imageElement {
references {
data = levelmedia:-1,slide
listNum = 0
}
renderObj = COA
renderObj {
10 = IMAGE
10 {
file.import.data = file:current:originalUid
altText.data = file:current:title
}
}
}
It do the trick, then it shows a diffrent image in the top/header on every page.
But thx...
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 <p 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).