[TYPO3-english] Add ID to body tag depends on DB value
Rachel Foucard
rfoucard at w-seils.com
Tue Mar 20 07:57:28 CET 2012
Hi,
You can simply use your TypoScript in the bodyTagCObject like that:
page.bodyTagCObject = COA
page.bodyTagCObject {
10 = CONTENT
10 {
table = tx_cagrelatedcontent_category
select {
pidInList = 14
selectFields = tx_cagrelatedcontent_category.uid
join = pages_tx_cagrelatedcontent_category_mm
where = tx_cagrelatedcontent_category.uid = pages_tx_cagrelatedcontent_category_mm.uid_foreign
andWhere = pages_tx_cagrelatedcontent_category_mm.uid_local = {page:uid}
andWhere.insertData = 1
}
renderObj = COA
renderObj {
10 = TEXT
10.field = uid
}
}
page.bodyTagCObject.wrap = <body class="cat|">
But don't forget that the webmaster can assign more than one category on a page, so you should limit the result of your select with a :
select.max = 1
With this code if there is no category assigned to the page, the body tag should be :
<body class="cat">
Regards,
--
RACHEL FOUCARD
Responsable Technique
www.w-seils.com
rfoucard at w-seils.com
-----Message d'origine-----
De : typo3-english-bounces at lists.typo3.org [mailto:typo3-english-bounces at lists.typo3.org] De la part de Stefano Kowalke
Envoyé : lundi 19 mars 2012 21:34
À : typo3-english at lists.typo3.org
Objet : Re: [TYPO3-english] Add ID to body tag depends on DB value
Hi,
now I got the correct uid from the database, but I don't know how to generate a body tag with the uid as ID.
temp.cat = CONTENT
temp.cat {
table = tx_cagrelatedcontent_category
select {
pidInList = 14
selectFields = tx_cagrelatedcontent_category.uid
join = pages_tx_cagrelatedcontent_category_mm
where = tx_cagrelatedcontent_category.uid = pages_tx_cagrelatedcontent_category_mm.uid_foreign
andWhere = pages_tx_cagrelatedcontent_category_mm.uid_local = {page:uid}
andWhere.insertData = 1
}
renderObj = COA
renderObj {
10 = TEXT
10.field = uid
}
}
One way would be putting the raw uid into the body tag (<body
id="cat_1">) but I need a CASE or globalVar there to put a more descriptive text as an ID.
Can I integrade a CASE inside the CONTENT object?
Stefano
Am 15.03.12 23:13, schrieb Urs Brm:
> Hi Stefano
>
> to simplify for debug, you could first go only fo the category uid,
> and set the number (with a prefix) into the body tag, like id="cat0",
> so you get rid of the join. Maybe that's even more robust. If that
> works, you can still add the join to spell out the category name later.
>
> Regards
> Urs
>
>
>
>
>
>
>
> Am 15.03.12 20:47, schrieb Stefano Kowalke:
>> Am 15.03.12 17:35, schrieb Philipp Gampe:
>>>> temp.category = CONTENT
>>>>> temp.category {
>>>>> table = tx_cagrelatedcontent_category
>>>>> select {
>>>>> selectFields = tx_cagrelatedcontent_category.uid
>>>>> join = pages_tx_cagrelatedcontent_category_mm
>>>>> where = tx_cagrelatedcontent_category.uid =
>>>>> pages_tx_cagrelatedcontent_category_mm.uid_foreign
>>>>> andWhere = pages_tx_cagrelatedcontent_category_mm.uid_local =
>>>>> {page:uid} andWhere.insertData = 1
>>>>> }
>>>>>
>>>>> renderObj = COA
>>>>> renderObj {
>>>>> 10 = TEXT
>>>>> 10 {
>>>>> required = 1
>>> Try dataWrap = debug:data here.
>>
>>
>> Ok tried this (with page.config.debug = 1). But nothing happend.
>> Should I see an output?
>>
>> Does this query work in phpmyadmin?
>>
>> Yes, it does.
>>
>> Stefano
>>
>>
>
>
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
More information about the TYPO3-english
mailing list