tt_news
1.7.4. TypoScript Examples:
Insert a news LATEST element in the left column, so that it is visible on all pages:
### News LATEST in left column
lib.newsLatest < plugin.tt_news
lib.newsLatest {
code >
code = LATEST
pid_list >
pid_list = 2,3 # the pids of the pages where your news are stored
catImageMode = 0
catTextMode = 0
}
# add tmp to page Object
page.subparts.NEWSLATEST < lib.newsLatest
If you don't use subparts in your TS, you can use something like this to insert "tmp.newsLatest" to your page object:
page.10.43 < lib.newsLatest
Render news-articles with graphical header in SINGLE view:
### SINGLE news with graphical header
plugin.tt_news {
displaySingle {
title_stdWrap.cObject = IMAGE
title_stdWrap.cObject.file = GIFBUILDER
title_stdWrap.cObject.file {
XY = [10.w]+2,30
backColor = #FFFFFF
10 = TEXT
10.text.field = title
10.text.case = upper
10.fontSize = 18
10.fontFile = t3lib/fonts/verdana.ttf
10.fontColor = #769400
10.offset = 1,20
10.antiAlias = 0
10.niceText = 1
}
}
}
The Category-Selector
[depreciated] Since tt_news 2.2.0 the category selector is a normal content element: CATMENU. So take this as a general TS example � maybe useful for other purposes.
This will insert a simple list of all tt_news categories from configurable folders to the left content-column. Clicking on a category link will display only news with the selected category. (highlights the current category)
### news Category Selector
page.10.subparts.left_content >
page.10.subparts.left_content = CONTENT
page.10.subparts.left_content {
table = tt_news_cat
select {
# the category folder(s)
pidInList = 124
}
renderObj = COA
renderObj.wrap = <div class="news-archive-item">|</div>
renderObj {
10 = TEXT
10.field = uid
10.dataWrap = <a href=index.php?id={TSFE:id}&tx_ttnews[cat]= | >
10.insertData = 1
20 = TEXT
20 {
field = title
wrap = <strong>|</strong>
if {
value.field = uid
equals.data = GPvar:tx_ttnews|cat
}
}
21 = TEXT
21 {
field = title
wrap = |
if {
value.field = uid
equals.data = GPvar:tx_ttnews|cat
negate = 1
}
}
30 = TEXT
30.value = </a><br />
}
}
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
10.stdWrap.if.isFalse.data = GPvar: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.
LIST and SINGLE at the same page
With a small TypoScript condition it's possible to show the news SINGLE view at the same page where the LIST is. This has some advantages for realUrl links:
Insert this to the setup field:
# clear the code field
plugin.tt_news.code >
plugin.tt_news.code = LIST
# prevent indexing of the LIST view
config.index_enable = 0
[globalVar = GP:tx_ttnews|tt_news > 0]
# set code to SINGLE if the GETvar tx_ttnews[tt_news] exists
plugin.tt_news.code = SINGLE
# enable indexing of the SINGLE view
config.index_enable = 1
[global]
# clear main content in page object
page.10.subparts.content >
# load tt_news as content to the page object
page.10.subparts.content < plugin.tt_news
How to get rid of the <p class="bodytext"> wrap ?
Add one of the following lines to your TS-Setup field:
# this will remove the complete <p> tag from all news content elements
plugin.tt_news {
general_stdWrap {
parseFunc.nonTypoTagStdWrap.encapsLines.nonWrappedTag >
}
}
# this will remove the complete <p> tag from ALL content elements
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.nonWrappedTag >
# This will remove the <p class="bodytext"> wrap from subheader, author and links
plugin.tt_news {
# unset general_stdWrap
general_stdWrap >
displayList {
# add a wrap to the subheader
subheader_stdWrap.wrap = <p>|</p>
}
displaySingle {
# add parseFunc to the subheader
subheader_stdWrap.parseFunc < lib.parseFunc_RTE
# prevent adding of <p> tags
subheader_stdWrap.parseFunc.nonTypoTagStdWrap.encapsLines.nonWrappedTag >
# add parseFunc to the bodytext
content_stdWrap.parseFunc < lib.parseFunc_RTE
# add parseFunc to the links field
linksItem_stdWrap.parseFunc < lib.parseFunc_RTE
# prevent adding of <p> tags
linksItem_stdWrap.parseFunc.nonTypoTagStdWrap.encapsLines.nonWrappedTag >
}
}