[TYPO3-english] Randomly Display tt_news Item with TypoScript

Scotty C superscotty19 at yahoo.com
Thu Jun 11 19:58:02 CEST 2015


Hi Loek,

Thanks for the reply! We're getting there - it's now limiting to just the category I need, but unfortunately, I'm still getting random image + first title only. Here's my exact code:


subparts.NEWS_ITEM = COA_INT 
subparts.NEWS_ITEM { 
10 = CONTENT 
10 { 

table = tt_news 


select { 
pidInList = 381 
max = 1 
orderBy = rand() 
join = tt_news_cat_mm ON uid=uid_local 
where = image != '' AND uid_foreign=22 
} #end select 

renderObj = COA 
renderObj { 

10 = IMAGE 
10 { 
wrap= <div>|</div> 
file.import=uploads/pics/ 
file.import.field=image 
file.import.listNum = 0 
file.width=180 
file.height=100c 
stdWrap.typolink.parameter.field = ext_url 
stdWrap.typolink.title.field = title 
} # end 10 

20=RECORDS 
20 { 
source = 381 
source.insertData = 1 
tables = tt_news 
conf.tt_news > 
conf.tt_news = TEXT 
conf.tt_news.field=title 
} 

} # end renderobj 

} # end 10 
} # end subpart



Result is:
- category 22 only
- image at random, but always the same title of the 1st item in the list, not the title that corresponds to the image.


What am I missing? (thanks again),
-Scott.






----- Original Message -----
> From: Loek Hilgersom <loek at netcoop.nl>
> To: typo3-english at lists.typo3.org
> Cc: 
> Sent: Thursday, June 11, 2015 4:47 AM
> Subject: Re: [TYPO3-english] Randomly Display tt_news Item with TypoScript
> 
> Hi Scotty,
> 
> You need to make a join with the tt_news_cat_mm table:
> 
> select {
>    pidInList = 381
>    max = 1
>    orderBy = rand()
>    join = tt_news_cat_mm ON uid=uid_local
>    where = image != '' AND uid_foreign=5
> }
> 
> You'll have to replace 5 by the uid of your category.
> Side note: this does not check if the category has been hidden or deleted, if 
> you need to check that, you also need to join with the tt_news_cat table.
> 
> Hth.
> Loek
> 
> 
> On 11-06-15 09:54, Scotty C wrote:
>>  Hi everyone,
>> 
>> 
>>  I have a categorized tt_news list of text+pic CEs. My goal is to use TS to 
> display one item at random in a subpart. For example:
>> 
>>  <title>
>>  <image>
>>  <text>
>> 
>>  I know that if I use this code, I'll get an image at random, but it 
> won't come from any category. I need it to only select images from a 
> specific category:
>> 
>>  subparts.NEWS_ITEM  = COA_INT
>>  subparts.NEW_ITEM {
>>    10 = CONTENT
>>    10 {
>> 
>>    table = tt_news
>>    select {
>>     pidInList = 381
>>         max = 1
>>         orderBy = rand()
>>         where = image != ''
>>       } #end select
>>       renderObj = COA
>>       renderObj {
>>         10 = IMAGE
>>         10 {
>>            wrap= <div>|</div>
>>            file.import=uploads/pics/
>>            file.import.field=image
>>            file.import.listNum = 0
>>            file.width=180
>>            file.height=100c
>>            stdWrap.typolink.parameter.field = ext_url
>>            stdWrap.typolink.title.field = title
>>         } # end 10
>> 
>>       } # end renderobj
>> 
>>    } # end 10
>>  } # end subpart
>> 
>> 
>> 
>>  .... and I know that if I use this code, I'll get the title of the 
> first item in the listing, but not random
>>  20=RECORDS
>>     20 {
>>       # id des template-records
>>       source = 381
>>       source.insertData = 1
>>       tables = tt_news
>>       conf.tt_news >
>>       conf.tt_news = TEXT
>>       conf.tt_news.field=title
>>     }
>> 
>> 
>>  .... but I need to put them together into one single block in the subpart! 
> Help!
>> 
>>  Thanks as always,
>>  -Scott.
>> 
> _______________________________________________
> 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