简体   繁体   中英

TT_NEWS Force Display of Latest News in Single/Latest implementatin (TYPO3)

Sirs,

I have a nice working implementation of SINGLE and Latest on same page. My realurl is working perfectly. Problem is, by default, single doesn't show anything until you click on one of the listed news (displayed by the list plugin). I would like the single plugin to show the latest news on landing.

Any ideas?

FIRST SOLUTION

The solution for the requested behavior is described in the tt_news manual :

Default news id

Insert the following lines to the setup field of an ext-template at the page where you want to display the latest news item in SINGLE view if no SINGLE view for another record was requested:

# hide the "no news id" message
plugin.tt_news._LOCAL_LANG.default.noNewsIdMsg =  
# set the tt_news singlePid to the current page
plugin.tt_news.singlePid = 977

# fill the content of the main-column to a tmp.object
tmp.pagecontent < page.10.subparts.contentarea

# clear the content of the main column
page.10.subparts.contentarea >

# build a new object for this column as content-object-array
page.10.subparts.contentarea = COA
page.10.subparts.contentarea {
  10 = CONTENT
  10.table = tt_news
  10.select {
# insert the pids of all pages from where you want to fetch news.
# the recursive-field has no influence on this selection
    pidInList = 1078,1079,1080,1081,1082,1083,1084
    orderBy = datetime desc
    max = 1
  }
# insert the object “10.” only if there is no SINGLE news selected
# ATTENTION, OUTDATED IN MANUAL, USE GP:... instead of GPvar:... !!!
  #10.stdWrap.if.isFalse.data = GPvar:tx_ttnews|tt_news
  10.stdWrap.if.isFalse.data = GP:tx_ttnews|tt_news
# re-insert the normal pagecontent to the page
  20 < tmp.pagecontent
}

The page in this example contains 2 columns. The news LIST is located in the left column. the main column (page.10.subparts.contentarea) contains a SINGLE news content-element.


SECOND SOLUTION – MY FAVORITE

My personal favorite to solve the problem is a bit more slick. It makes use of the noNewsIdMsg (which is simply emptied in the above solution) and uses its stdWrap version to show the latest record exactly when there would normally be a "No news ID" message.

# use the "no news id" message position for the latest news record
plugin.tt_news.singlePid = 977
plugin.tt_news.noNewsIdMsg_stdWrap.cObject = COA
plugin.tt_news.noNewsIdMsg_stdWrap.cObject {
  10 = CONTENT
  10.table = tt_news
  10.select {
    # insert the pids of all pages from where you want to fetch news.
    # the recursive-field has no influence on this selection
    pidInList = 1078,1079,1080,1081,1082,1083,1084
    orderBy = datetime desc
    max = 1
  }
}

Please be aware that in BOTH solutions the template subpart that is used for the inserted default record is NOT ###TEMPLATE_SINGLE### but ###TEMPLATE_SINGLE_RECORDINSERT###.

One solution is to change the text limit for latest view in that particular news plugin as given below:

plugin.tt_news.displayLatest.subheader_stdWrap.crop = 10000 | ... | 1

and also provide a separate template file without

<!--###LINK_ITEM###-->

markers in latest view section.

The Safe Single News extension

adds a new tt_news code: SAFE_SINGLE which ensures that a single news article is shown even if none is specified. If a news article is selected, it will simply show it. If none is selected, it will display the latest news article for the configured category.

Maybe it could help you.

Why not have a "single/latest" view showing a single view (if submitted) and latest if no single view requested. In this plugin set news-limit for latest to "1".

Below add another latest (or list) with news limit set to 3 (or as wanted)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM