Custom bodytext wrapping in TYPO3 - typo3

I create a new frame using this code:
In Page TSConfig:
TCEFORM.tt_content.section_frame {
addItems.104 = Accordion
}
and in setup:
tt_content.stdWrap.innerWrap.cObject = CASE
tt_content.stdWrap.innerWrap.cObject {
key.field = CType
default = CASE
default {
key.field = section_frame
# Wrapping whole CE
104 = TEXT
104.value = <li>|</li>
}
}
Everything working fine but I need to change one more thing, and I don't know if it's possible.
I will be using this frame only for text content element and I need to wrap whole bodytext in <div class="content">|</div> element. Is it possible?

I figured out:
tt_content.stdWrap.innerWrap.cObject = CASE
tt_content.stdWrap.innerWrap.cObject {
key.field = section_frame
104 = TEXT
104.value = <li>|</li>
}
tt_content.text.20.innerWrap.cObject = CASE
tt_content.text.20.innerWrap.cObject {
key.field = section_frame
104 = TEXT
104.value = <div class="content">|</div>
}
lib.stdheader.stdWrap.outerWrap.cObject = CASE
lib.stdheader.stdWrap.outerWrap.cObject {
key.field = section_frame
104 = TEXT
104.value = <div class="title">|</div>
}

Related

TYPO3 loading object based on current front end language

I'm running a Typo3 v9.5.4 Onepager style Website. The content is loaded directly from the tt_content. The Website has two FE languages (German/English).
I have a CTA button which has an anchorlink. The button is create with typoscript. I created one button for the German version and one for the English verson bc they have another value and another ancorlink.
I'm not sure if I can access a tt_content field directly from a fluid viewhelper. This is my code i've tried
<f:if condition="{tt_content.sys_language_uid} == 1">
<f:then>
<f:format.raw>{buttonEn}</f:format.raw>
</f:then>
<f:else>
<f:format.raw>{buttonDe}</f:format.raw>
</f:else>
</f:if>
This is my Typoscript for the two button Objects
lib.buttonDe = TEXT
lib.buttonDe {
value = German Text
stdWrap.typolink.parameter = #anchorlinkDE
stdWrap.typolink.ATagParams = class="button"
}
lib.buttonEn = TEXT
lib.buttonEn {
value = English Text
stdWrap.typolink.parameter = #anchorlinkEN
stdWrap.typolink.ATagParams = class="button"
}
And this is the typoscript that loads the Content, the Languages Menu and the Fluidtemplate (the Onepager Content is loaded without a Fluidtemplate, it loads the content directly from tt_content):
//--------------------- One Pager Content
lib.sectionContent = HMENU
lib.sectionContent {
excludeUidList = 12,13,16,17,29
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap >
stdWrap {
cObject = COA
cObject {
if.value = 4
if.equals.field = doktype
if.negate = 1
10 < temp.titleSectionId
10.wrap = <section id="|">
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
orderBy = colPos,sorting
# Only selects Content where CE Layout is 0
where = (tt_content.layout = "0")
}
wrap = <div class="container">|</div>
renderObj < tt_content
}
30 = TEXT
30 {
wrap = </section>
}
}
}
}
}
}
//---------------------
// Language Selector
lib.langmenu = HMENU
lib.langmenu {
special = language
addQueryString = 1
special.value = {$config.language.uids}
1 = TMENU
1 {
wrap = <ul class="dg-langmenu row">|</ul>
NO = 1
NO {
stdWrap.current = 1
stdWrap.setCurrent = {$config.language.labels}
allWrap = <li class="col s6">|</li>
}
ACT < .NO
ACT.doNotLinkIt = 1
ACT.allWrap = <li class="act col s6">|</li>
}
}
page = PAGE
page{
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap{
cObject = TEXT
cObject{
data = levelfield:-2,backend_layout_next_level,slide
override.field = backend_layout
split {
token = pagets__
1.current = 1
1.wrap = |
}
}
ifEmpty = onePager
}
templateRootPaths {
10 = {$path.privat}Templates/
}
layoutRootPaths {
10 = {$path.privat}Layouts/
}
partialRootPaths {
10 = {$path.privat}Partials/
}
variables{
buttonDe < lib.buttonDe
buttonEnd< lib.buttonEn
}
}
So I'd like to load the buttonEn if the content has the sys_language_uid 1 (English) else I want it to load the buttonDe.
Do I need to create an Typoscript Object and then load this Object into the f:if viewhelper? If so how do I create this Typoscript Object.
Thanks for your help!
The easy way (pure typoscript)
lib.button = TEXT
lib.button {
value = English text
lang.de = Deutscher Text
stdWrap.typolink.parameter = #anchorlinkDE
stdWrap.typolink.ATagParams = class="button"
}
[siteLanguage("locale") == "en_EN.UTF-8"]
lib.buton.stdWrap.typolink.parameter = #anchorlinkEN
[global]
but the professional solution is configuring your labels in a language file (see answer from Thomas Löffler) and use:
lib.button = TEXT
lib.button {
lib.button.data = LLL:EXT:site_extension/Resources/Private/Language/locallang.xlf:button_label
stdWrap.typolink.parameter = #anchorlinkEN
stdWrap.typolink.ATagParams = class="button"
}
[siteLanguage("locale") == "de_DE.UTF-8"]
lib.buton.stdWrap.typolink.parameter = #anchorlinkDE
[global]
For language dependent constant data you might use typoscript conditions to redefine a value for your non default languages. (or define a fallback and conditions for each language.)
You should use a locallang file and refer to it in TypoScript.
Create a locallang file (copy an existing and remove all values) named locallang.xlf
Add your english label in there
Create a locallang file in the same folder with prepending de. in the filename (de.locallang.xlf) and add the german label
Refer to it in the TypoScript by using lib.button.data = LLL:EXT:your_ext/path/to/locallang/locallang.xlf:buttonLabel, see https://docs.typo3.org/typo3cms/TyposcriptReference/DataTypes/Index.html#lll
This TS getText function gets the label depending on the set language ID automatically and you only need one TS for the button.
Example: https://docs.typo3.org/typo3cms/TyposcriptIn45MinutesTutorial/UsingGetText/Index.html

Typo3 how to get a <li> wrapped around an typolink link list

Hi I try to get the following out-put when including a .lib with
<f:cObject typoscriptObjectPath="lib.faqList"/>
in my fluid template. I get the links out put but not in the desired:
`<ul>
<li>
some text here
</li>
</ul>
`
So this is the lib.faqList I tried to wrap in several ways but can not get it working also tried with {} and wrap stdWrap linkWrap etc. So how should thsi be done. I now get the ul and the links without the li?
`## Linklist FAQ!! [Begin]
lib.faqList = COA
lib.faqList{
wrap = <ul>|</ul>
lib.faqList.10 = TEXT
lib.faqList.10.stdWrap = <li>|</li>
{lib.faqList.10.value = TYPO3 Association
lib.faqList.10.typolink.parameter = 29
}
lib.faqList.20 = TEXT
lib.faqList.20.stdWrap = <li>|</li>
{lib.faqList.20.value = TYPO3 Association
lib.faqList.20.typolink.parameter = http://association.typo3.org
}
lib.faqList.30 = TEXT
lib.faqList.30.stdWrap = <li>|</li>
{lib.faqList.30.value = TYPO3 Association
lib.faqList.30.typolink.parameter = 27
}
lib.faqList.40 = TEXT
lib.faqList.40.stdWrap = <li>|</li>
{lib.faqList.40.value = TYPO3 Association
lib.faqList.40.typolink.parameter = 98
}
}
## Link list [End]
`
Watch on you code, I see many bracet where they not belong...
## Linklist FAQ!! [Begin]
lib.faqList = COA
lib.faqList {
wrap = <ul>|</ul>
10 = TEXT
10 {
wrap = <li>|</li>
value = TYPO3 Association
typolink.parameter = 29
}
20 = TEXT
20 {
wrap = <li>|</li>
value = TYPO3 Association
typolink.parameter = http://association.typo3.org
}
30 = TEXT
30 {
wrap = <li>|</li>
value = TYPO3 Association
typolink.parameter = 27
}
40 = TEXT
40 {
wrap = <li>|</li>
value = TYPO3 Association
typolink.parameter = 98
}
}
## Link list [End]

TYPO3 Menu Double up

I have this custom menu setup based on the default section menu. When testing on one content element, it looks good... When I add a second content element to the page both get added to each menu item.
Anyone know what's going on here?
tt_content.menu.20.3.1.sectionIndex.useColPos = -1
tt_content.menu.20.101 < tt_content.menu.20.3
tt_content.menu.20.101 {
1.NO {
stdWrap.cObject = CONTENT
stdWrap.cObject {
table = tt_content
select {
pidInList.field = uid
}
renderObj = COA
renderObj {
10 = FILES
10 {
stdWrap.wrap = <div class="menu-img">|</div>
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 100c
height = 100c
}
altText.data = file:current:alternative
titleText.data = file:current:title
stdWrap.typolink.parameter.data = file:current:link
}
maxItems = 1
}
20 = TEXT
20.field = header
30 = TEXT
30.field = rowDescription
}
}
}
}
This is currently outputting:
<ul>
<li><img/>Heading1Desc1<img2/>Heading2Desc2</li>
<li><img/>Heading1Desc1<img2/>Heading2Desc2</li>
<ul>
What it should be:
<ul>
<li><img/>Heading1Desc1</li>
<li><img2/>Heading2Desc2</li>
</ul>
It is about your CONTENT object.
your selection is strange:
select {
pidInList.field = uid
}
you select all tt_content elements which are in the page with the uid of the current content element.
And your rendering is executed for each record found.
Do you really need to select the contentelement with a cObject again? I think in the menu it should be the current context.
add on:
I would try something like this to render the image before the text (which should be available by default):
before just for the image instead of stdWrap with a full query of all CEs and with a COA for all fields.
have a look to the correct fieldname!
1.NO {
before.cObject = FILES
before.cObject {
stdWrap.wrap = <div class="pic">|</div>
references {
table = tt_content
uid.data = uid
// 'image' or 'media' or ... ???
fieldName = image
}
renderObj = IMAGE
renderObj {
stdWrap.wrap = <div class="pic">|</div>
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 150c
height = 150c
}
altText.data = file:current:alternative
titleText.data = file:current:title
#params = class="menu-img"
// don't do a link inside a link =:-O
#stdWrap.typolink.parameter.data = file:current:link
}
maxItems = 1
}
}
I have tried this many different ways and cannot get it working with the image and fields. So instead I have simply patched my original code using by adding: tt_content.menu.20.101.maxItems = 1 and adding a wrap to the renderObj.
I know this is not how it should be done, but it works for now. But if anyone knows the correct way of doing it let me know!

Typolink inside section menu COA

I have a custom section menu where I need a specific part of the menu item to be linked instead of the whole thing.
At the moment the typolink part doesn't do anything:
tt_content.menu.20.101 < tt_content.menu.20.3
tt_content.menu.20.101 {
1.NO {
doNotLinkIt = 1
stdWrap.htmlSpecialChars = 0
stdWrap.cObject = CONTENT
stdWrap.cObject {
table = tt_content
select {
pidInList.field = uid
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
10.typolink {
section.cObject = TEXT
section.cObject.field = uid
section.cObject.wrap = c|
}
20 = TEXT
20.field = rowDescription
20.wrap = <h6>|</h6>
}
}
}
}
So the output I want from the example above would be something like:
<ul>
<li>Element HeaderElement Description etc..</li>
</ul>
in the documentation you will find two possibilies:
insert the complete anchor (with hash) into parameter
use .section in combination with a page id for parameter (assuming the anchor is on another page)
that gives two solutions:
typolink {
paramter.cObject = TEXT
paramter.cObject {
field = uid
wrap = #c|
}
}
or
typolink {
parameter.field = pid
section.cObject = TEXT
section.cObject.field = uid
section.cObject.wrap = c|
}

Add image to menu/sitemap element in TYPO3

I am using TYPO3 4.7 (Upgrading is not an option). Can I customize the Menu/Sitemap element to include the first image on each linked page?
So In this case I'd be using:
tt_content.menu.20.1.1.NO
First of all you really should update the site as there are a lot security issues which can do harm to your/your customer's website.
Back to your question: Of course you can render any content inside a menu as well!
lib.menu = HMENU
lib.menu {
wrap = <ul>|</ul>
1 = TMENU
1.NO {
wrapItemAndSub = <li>|</li>
after.cObject = CONTENT
after.cObject {
table = tt_content
select {
pidInList.field = uid
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
10.htmlSpecialChars = 1
20 = TEXT
20 {
field = image
split {
token = ,
cObjNum = 1
1 {
10 = IMAGE
10 {
file {
import=uploads/pics/
import.current = 1
width = 170
height = 100
}
}
}
}
}
}
}
}
}
tt_content.menu.20.1.1.NO < lib.menu.1.NO
To be honest: the part with the image is untested as I don't have any non-FAL (since 6.0) installation anymore where I could test it.