[TYPO3-english] Randomly Display tt_news Item with TypoScript
Loek Hilgersom
loek at netcoop.nl
Thu Jun 11 12:47:06 CEST 2015
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.
>
More information about the TYPO3-english
mailing list