Can I filter TT_NEWS in Typo3 by a date range? - date

I'm building a Typo3 website with the TT_NEWS extension; now I want to create a TT_NEWS list/latest view with a certain date range, but I cant find a way to do so.
I can't use the ARCHIVE function because I need a specific data range.
I hope that one of you knows the magic answer :-)

You can try setting an exact date range for the archive with TypoScript:
plugin.tt_news.amenuStart = 1.2.2003
plugin.tt_news.amenuEnd = 4.5.2006
This is assuming you only need one date range. For more than one range, maybe news categories would do the trick, but you'd need to assign them manually.

For tx_news use this in TypoScript:
1.settings.timeRestriction = 01.02.2003
1.settings.timeRestrictionHigh = 04.05.2006

Related

TYPO3 tx_news entries within a date range

I am currently migrating tt_news to news. The old news system also has news-entries shown as events. Is it somehow possible to hide entries that are past, without having to archive those? Or else to show only entries within the next x days?
This was possible with tt_news typoscript:
extensions.ttnews_selectconf {
andWhere (
tt_news.datetime < (UNIX_TIMESTAMP() +604800)
AND tt_news.datetime > (UNIX_TIMESTAMP()-86400)
)
}
I could not find anything in the news docs.
The news extension has a TypoScript option to set a minimum date/time: https://docs.typo3.org/typo3cms/extensions/news/stable/AdministratorManual/Configuration/TypoScript/Index.html#timerestriction
So plugin.tx_news.settings.timeRestriction = now will show news items starting now. plugin.tx_news.settings.timeRestriction = today will show news items starting at the start of today.
For a maximum date you can use timeRestrictionHigh
Also, if you're using news for events, you might want to check out the eventnews extension. This extends the news extension to add fields and views that are useful for events. https://extensions.typo3.org/extension/eventnews

TYPO3, news: change sort order and direction via get parameter

in a list view of extension news we need links which change the sort order and the sort direction. Is there a possibility to change both via get parameters?
I unchecked the option "Disable override demand" and tried some combinations like
?tx_news_pi1[orderDirection]=asc
?tx_news_pi1[settings][orderDirection]=asc
but this doesnt work.
Thanks!
tx_news_pi1[overwriteDemand][order]=title desc works for me
Maybe try:
tx_news_pi1[overwriteDemand][orderDirection]=asc
(while i am not really sure if orderDirection is correct, mayb check manual/code of that)
As far as I see there is no intuitive option to include sorting in the fluid-templates as all sorting is done on the level of TypoScript respectively FlexForm.
There are different options to enable sorting from frontend nevertheless:
In TypoScript you set the sorting-parameters depending on the current URL-parameters, the easiest way would be to solve it by conditions, also you'd be free to define own parameters without sticking to the news-API.
The URLs for sorting you should create in any case with a viewHelper that the cHash is always appended and calculated correct.
TypoScript:
#######
## Here you transfer the URL-parameters for sorting to the TypoScript-settings
## and also assure that only predefined values are accepted
#######
[globalVar = _GET|tx_news_pi1|orderBy = title]
plugin.tx_news.settings.orderBy = title
[globalVar = _GET|tx_news_pi1|orderBy = datetime]
plugin.tx_news.settings.orderBy = datetime
[globalVar = _GET|tx_news_pi1|orderBy = tstamp]
plugin.tx_news.settings.orderBy = tstamp
[globalVar = _GET|tx_news_pi1|orderBy = crdate]
plugin.tx_news.settings.orderBy = crdate
[global]
[globalVar = _GET|tx_news_pi1|sort = desc]
plugin.tx_news.settings.orderDirection = desc
[else]
plugin.tx_news.settings.orderDirection = asc
[global]
Fluid:
<f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=asc">Sort by title: asc</f:link.action>
<f:link.action action="list" addQueryString="&tx_news_pi1[orderBy]=title&tx_news_pi1[sort]=desc">Sort by title: desc</f:link.action>
This solution is not tested and it might be required still to adjust some things but in general it should be working.
Cache-related issues are considered the same as with news-records in general, at least related to any required settings.
Sorting by further fields requires further steps as stated here:
https://docs.typo3.org/typo3cms/extensions/news/DeveloperManual/ExtendNews/ExtendFlexforms/Index.html#selectbox-sort-by
Other individual solutions require programming in PHP and can base on hooks as well as on signals, the news-manual includes several chapters that might be useful:
Signals
Hooks
Extension based on EXT:news
Furthermore it might be possible that there exist extensions that solve the sorting-job already but I'm not aware of it. You could search for news-related extensions. I could imagine that eventnews or dataviewer could be useful perhaps but I never checked that out and these extensions never might be useful at all for it.
Also it's possible that you discover another useful extension on further search. If so, let us know ;-)
Then there is still the option that somehow the desired behavior can be solved different, perhaps it's not or bad documented or I missed it.
Consider that you probably still have to tweak a bit if you use pagination and especially AJAX based pagination.
I found the reason for the problem and a work around.
the reason is the default sorting in the flexform: sorting by title. The GET-Parameter orderBy cannot overwrite the default sorting in the flexform. If you choose a default sorting in the flexform the orderBy parameter ist ignored but the orderDirection parameter works as expected. The result is confusing but consistent: the content ist always sorted by the default sorting but with different sortOrders.
After deleting the default sorting in the flexform all works as expected.
I presume this is a kind of a bug; i will post a question in the bug tracker of news.

How force a template file in tt_news LIST?

I have a list in tt_news and use many folders with tt_news records. I want to use a different template in this list when I filter and display specific category.
My Typoscript is:
[globalVar = GP:tx_ttnews|place|0 = 79]
#Display list of specific category
plugin.tt_news.templateFile = fileadmin/templates/plugins/tt_news/different.html
[else]
#General display list
plugin.tt_news.templateFile = fileadmin/templates/plugins/tt_news/general.html
[end]
I have used plugin.tt_news.templateFile and plugin.tt_news.file.templateFile but don't work. I am using the last version of tt_news and TYPO3 6.2
"plugin.tt_news.templateFile" is right, i think there is a problem in "[globalVar = GP:tx_ttnews|place|0 = 79]" you should close global with "[global]" instead of "[end]". Try this if it is helpful to you.
For the Typoscript way did not resolve this, I do not why? For we needed we have use a category and marker in the template of tt_news and create a logic in frontend through JS for resolve this.

TYPO3 news (tx_news) ordering of records not working

I'm running TYPO3 V6 and the latest version of tx_news (not tt_news) and when I attempt to change the order of sorting for the LIST display, the settings in the plugin are not overriding the Typoscript settings. There doesn't seem to be a way to change to sort order of articles in the list view. I am aware that flagging a news record as "top news" will float it to the top of the list, but none of my records have that flag set.
Has anyone else had this problem?
I got the same problem: My listview always showed the oldest news on the top. I've been searching for a solution for hours. As i wanted to start to change the extension files manually, I found the "setup.txt" in the configuration folder. From there I copied the following code into my Typoscript. The problem is solved now.
plugin.tx_news{
settings{
overrideFlexformSettingsIfEmpty = cropMaxCharacters,dateField,timeRestriction,orderBy,orderDirection,backPid,listPid,startingpoint,recursive
orderBy = datetime
orderDirection = desc
orderByRespectTopNews = 0
orderByAllowed = sorting,author,uid,title,teaser,author,tstamp,crdate,datetime,categories.title
list{
paginate {
itemsPerPage=4
insertBelow=TRUE
lessPages=TRUE
#forcedNumberOfLinks=3
pagesBefore=1
pagesAfter=1
}
}
}
}
You can ignore the pagination lines. Important is the orderby stuff.
Typo3 Version: 4.7 (not my fault :D )
News System Version: 2.3
Found the solution to this one - basically I had been loading the TS setup code from an external file, which was overriding the default TS setup from the Typoscript template setup field, or rather, it wasn't. I duplicated the TS code in the Typoscript template and the external file and finally it is being recognised and the fields can be sorted.

reformat date that is pulled from database table

I have a website which uses smarty templates.
I have a table in my db called posts that has various columns, one being "date_added". I managed to have that displayed on the posts by editing one of the Smarty templates for "posts" however, the date format is YYYY-MM-DD.
Is there any easy way for me to change this? Perhaps with jQuery?
Ideally, I want to only show the abbreviated month, with the day positioned next it. This is for a blog style post, but this isn't WordPress.
Right now the smartytemplate the shows the date_added reads like this:
{$posts[i].date_added|stripslashes|nl2br}
Where posts is the table and date_added is a column in that table.
An exact example can be seen here in the top right corner of each post.
http://www.elegantthemes.com/preview/LightBright/
Does anyone have a good suggestion of how I can achieve the desired request?
If you are looking for a javascript solution, you can take a look at the incredible JS Library MomentJS. It is very lightweight and does numerous date and time formats.
http://momentjs.com/
Just include the minified script file in your HTML .
For your exact case, you would use momentJS as such:
First create the momentJS date object:
var moment_date = moment(date_from_database, "YYYY-MM-DD");
Then to display the date as you want:
var date_string = moment_date.format("MMM DD"); // ex. = "Mar 03"
More documentation here: http://momentjs.com/docs/#/displaying/
Then you can use your DOM manipulation library (JQuery for example) to place that string somewhere in your HTML
Good luck
- K