-->

TYPO3 lib HTML and TEXT code

2019-09-09 02:41发布

问题:

I want to show i LIB on my page, but it will be showed on the page all my sits, but not the site with Uid = 3 So in my main TS i have, this

[globalVar = TSFE:id <> 3]
.....
[end]

My question is now, how do i setup a lib, thats have some text and HTML content in it.. Lets say that its this i want to show

<div class="ProductListTitle_style1">
my text my text
<p> text text text...&nbsp;</p>
</div>

回答1:

You can use lib = COA in combination with TEXT and IMAGE

lib.b = COA
lib.b {
    wrap = <div class="ProductListTitle_style1">|</div>

    10 = TEXT
    10.value = my text my text

    20 = TEXT
    20.value = text text text...&nbsp;
    20.wrap = <p>|</p>

    30 = IMAGE
    30.file = path/to/file.png
    30.altText = My image
    30.width = 300

}

Before TYPO3 6.0 you could use lib = HTML.

lib.a = HTML
lib.a.value (
<div class="ProductListTitle_style1">
my text my text
<p> text text text...&nbsp;</p>
</div>
)

You can also combine the two possibilities

lib.c = COA
lib.c {
    wrap = <div class="ProductListTitle_style1">|</div>

    10 = TEXT
    10.value = my text my text

    20 = HTML
    20.value = <p> text text text...&nbsp;</p>
}


回答2:

Just for clarification: In TYPO3 4.5+, the Content Objects TEXT and HTML have the same functionality. So you can of course put HTML tags in a TEXT object:

lib.something = TEXT
lib.something.value = <p>My Text</p>

Since both objects could do the same since TYPO3 4.5, the HTML cObject was deprecated and removed in 6.0.

As for Thomas question about COA: A COA is a "content object array" and thus an array of content elements. A COA is used when more than one content needs to be combined in one TypoScript object. So if you just have one object (as in my example above), you don't need a COA, but if you have more than one content, use it (as in hildende's first example).