2

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?

Sankar V
  • 4,110
  • 5
  • 28
  • 52
John Miller
  • 527
  • 4
  • 15
  • 1
    Ok, so after hacking away for a few more minutes, I've come to the conclusion that its nearly impossible to implement this without having to mess up with the tt_news extension code. To save everybody a lot of problems, simply install extension: xw_ttnewslatestsingle from ter, then add right after
    in your default tt_news template. Then, open your SINGLE plugin and change its status to SINGLELATEST. Save and enjoy! Works perfectly!
    – John Miller Feb 16 '13 at 15:41
  • Please accept an answer or post your solution as an answer and accept it. – Sankar V Feb 19 '13 at 07:27

4 Answers4

1

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###.

Jpsy
  • 20,077
  • 7
  • 118
  • 115
0

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.

Sankar V
  • 4,110
  • 5
  • 28
  • 52
0

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.

Charles Brunet
  • 21,797
  • 24
  • 83
  • 124
0

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)

kraftb
  • 625
  • 5
  • 15