[TYPO3] TS for specific [news, or other] content elements

Tyler Kraft tyler.kraft at netefficiency.co.uk
Sun Jun 29 01:11:58 CEST 2008


Ok well (to me at leaat) what you actually want to be doing is pulling 
out the content record using the CONTENT object and then starting to 
redefine the output/rendering of it. That way you don't actually need to 
use any condition. By default CONTENT will jsut renedr things the same 
way tt_content does, but you can define a custom rendering for it as well...

And what I'd do is for each one you build I'd move all the typoscript to 
an external file that gets referenced in (1file per 1 content/tt_news 
item) - that way once you have one working and move it to a file its 
less liekly to get accidentally 'hurt' or overwritten or altered.

hth



Kathryn Blair wrote:
> Hi Tyler,
> 
> Thanks. Sorry that I didn't explain the entire story of what I'm doing -- I
> only explained the specific thing I wanted (a condition to target content
> elements by uid in tt_content). Here's the rest of the story. 
> 
> I'm working on a site that's going to have a lot of news elements embedded
> in the layout. Yes, I'm calling out specific tt_content records. In this
> case they're tt_news content elements. I'm placing them in the layout via
> typoscript. I've got that done and working beautifully. Often, multiple news
> elements will be displayed on one page. These news elements will all look
> different, so I want to set typoscript for one specific element, and not
> have it affect any of the others. I can't use GPVars because these news
> elements are being displayed independently of them. 
> 
> I want to do is write some typoscript that will only apply to one specific
> content element (so this content element with uid 1316 will have the
> typoscript I've written for it applied, and any other content element that
> happens to be a tt_news element will not have the changes applied. I don't
> necessarily need to do this with conditions, it just seems like it might be
> the most flexible thing to do, which would be easy to use to target almost
> anything.
> 
> From what I gleaned reading the Conditions page of the TSREF*, globalVar
> will match numeric values, and globalString will match characters. So if you
> wanted to match pages with title "hi", you would use globalString like this:
> 
> [globalString = TSFE:page|title = hi]
> 
> And you use global var to match numbers, like
> 
> [globalVar = TSFE:page|uid = 332]
> 
> So because TSFE:cObj|currentRecord prints "table:uid", I used globalString
> because it includes the title of the table:
> 
> [globalString=TSFE:cObj|currentRecord=tt_content:1316]
> plugin.tt_news.templateFile=fileadmin/Arts_Co-op/templates/news_templates/ar
> ts-co-op-headlines.tmpl
> [global]
> 
> But I must be either doing something wrong because I can't get that to work
> in a condition, or it just doesn't work in conditions. Works for just
> grabbing the data though.
> 
> I also tried using .if**, but it doesn't seem like that works past just
> rendering the object or not. So I could do:
> 
> dates.10.if 
> .....
> 
> and decide whether to render the object "dates.10", but I can't do
> 
> dates.10.wrap.if 
> ....
> 
> and determine whether or not to wrap it, so it doesn't look like that will
> work for the template file / other plugin.tt_news setting, because it would
> have to be
> 
> plugin.tt_news.templateFile.if
> ....
> 
> 
> I'm now using an alternate approach I saw here:
> http://www.typo3-jack.net/typo3-english-lists-netfielders-de/11808-typo3-how
> -set-typoscript-specific-content-element.html
> 
> It works, but it means that all of the options (categories, number of items
> to display, etc) for the object are set via typoscript, which is not ideal
> because I won't be maintaining the site. 
> 
> 
> *
> http://typo3.org/documentation/document-library/references/doc_core_tsref/4.
> 1.0/view/4/1/
> **
> http://typo3.org/documentation/document-library/references/doc_core_tsref/4.
> 1.0/view/5/7/  
> 
>  
> 
> Message: 8
> Date: Fri, 27 Jun 2008 13:14:14 +0100
> From: Tyler Kraft <tyler.kraft at netefficiency.co.uk>
> Subject: Re: [TYPO3] TS for specific [news, or other] content elements
> To: typo3-english at lists.netfielders.de
> Message-ID:
> 	<mailman.1.1214568993.5985.typo3-english at lists.netfielders.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hi,
> 
> Prehaps I'm missing the idea here, but are globalVar and globalString 
> not two different things? And if you want to test for a specific news 
> record displaying  wouldn't you use tx_ttnews[tt_news]=401 and do 
> something like
> 
> [globalVar = GP:tt_news=401]
> or
> [globalVar = GP:tx_ttnews|tt_news=401]
> 
> What exactly are you trying to do? (you don't really explain that here) 
> Are you wanting to draw out one specific record and place it on one 
> specific page (with out it being in the BE page content)? Can you please 
> give a better description of what you want to achieve
> 
> Tyler
> 
> Kathryn Blair wrote:
>> Hi everyone,
>>
>> I want to be able to set separate TS for specific news content elements.
>> I've seen some potential info inline for this, but not ones which made it
>> clear to me how I could adapt them to what I wanted to do. 
>>
>> What I REALLY want to do is use a condition to target a specific news
>> elemenet based on its uid (in tt_content). I saw an example here: 
>>
>>
>> [globalVar = TSFE:tt_content|uid = 37]
>> plugin.tt_news._LOCAL_LANG.de.preAuthor = Autor:
>> [global]
>>
>> The reason this doesn't work (and should be taken off that site -- if I
> can
>> figure out an alternate method I'll replace it) is because [globalString =
>> TSFE:fe_user|user|username = test] is not basing it's true/falseness on
> the
>> table fe_user, but the variables in the TSFE. I don't know a lot of PHP,
> but
>> I went on an odyssey trying to figure this out and this is what I've got:
>>
>> There is no tt_content variable for TSFE, but there is a cObj variable.
>> (which I saw here:
>>
> http://www.typo3-unleashed.net/typo3apidocs/typo3api_4.0.0/html/d8/d11/class
>> _8tslib__fe_8php-source.html). cObj also has variables [sorry if my
>> terminology is off], including $currentRecord, which "is set to the
>> [table]:[uid] of the record delivered in the $data-array, if the cObjects
>> CONTENT or RECORD is in operation. Note that
> $GLOBALS['TSFE']->currentRecord
>> is set to an equal value but always indicating the latest record
> rendered."
> (http://www.typo3-unleashed.net/typo3apidocs/typo3api_4.0.0/html/da/d2c/clas
>> stslib__cObj-members.html). Yay, you would think this would solve all of
> my
>> problems!
>>
>> Well, this ts does render the table:uid (in this case, because I just put
>> the typoscript in a template, that was pages:uid-of-current-page):
>>
>>     20 = TEXT
>>     20.data = TSFE:cObj|currentRecord
>>     20.wrap = TSFE=|<br />
>>
>> but I can't seem to write a condition based on this that is successful in
>> targeting the specific content object. Here's what I'm trying:
>>
>> [globalString=TSFE:cObj|currentRecord=tt_content:1316]
>>
> plugin.tt_news.templateFile=fileadmin/Arts_Co-op/templates/news_templates/ar
>> ts-co-op-headlines.tmpl
>> [global]
>>
>> I know that
>>
> plugin.tt_news.templateFile=fileadmin/Arts_Co-op/templates/news_templates/ar
>> ts-co-op-headlines.tmpl is correct because I tried it with other
> conditions
>> (TSFE:id=321). I know I can set template files on the tt_news content
>> element page itself, but the tt_news manual says that it's better to do so
>> via ts, and I was hoping that doing it via TS I wouldn't have to erase and
>> reset the template every time I update the file. Also, I might need to set
>> some other ts this way, and it seems like a logical thing to want to do,
>> from my perspective. 
>>
>> I'm sure either I just don't fully grasp how currentRecord is supposed to
>> work (which would make me sad, unless someone knows a different way to do
>> this), or I'm just doing something incorrectly. If there's some massively
>> easier way to do this, please let me know -- although like I said I didn't
>> think (or understand how) the other solutions I'd seen would work for me. 
>>
>> Here's the ts I'm using to grab the tt_news element and stick it in my
>> template:
>>
>> dates.10=CONTENT
>> dates.10.table = tt_content
>> dates.10.select.pidInList=879
>> dates.10.select.uidInList=1316
>> dates.10.select.wrap = <div class="important-dates-employers"> | </div>
>>
>> Thanks for any help in advance,
>>
>> Kath
>>
> 
> 
> 
> 


More information about the TYPO3-english mailing list