[Typo3] [tt_news] wrapping non-archived (latest?) news
Charles Rector
crector at iexposure.com
Sun May 8 22:43:29 CEST 2005
Joey,
My archive setting is on "Don't Care" so all items show up. I have read
up on "if" quite a lot, but it is proving difficult to manage.
Perhaps I am going about this the wrong way.
I do not want to set the archive dates for all my news items -- I have
hundreds of them. But if I did set them, this code does what I want:
displayList.title_stdWrap {
wrap = <span style="color:red; font-weight: bold">New!</span> |
if {
value.data = date:U
isGreaterThan.field = archivedate
}
}
Which basically says, if the archive date for the news item is in the
future, that means it's a "new" item.
However, I need to be able to *calculate* when a news item is old (in a
similar way tt_news calculates to determine when to archive a news item.)
In order to do that, I have to perform some math in the .data field, but
from testing I don't think it allows mathematical expressions.
For example, this does not work:
displayList.title_stdWrap {
wrap = <span style="color:red; font-weight: bold">New!</span> |
if {
# calculate how old the news item is (UNIX time)
value.data = date:U - field:datetime
# if a full day (24 hours) is greater than how old the news is
isGreaterThan = 24*60*60
}
}
If the news item was 12 hours old, it would get decorated with "New!".
If the news item was 36 hours old, it would not.
Do you see what I am trying to do?
JoH wrote:
>>I have set the following:
>>
>>plugin.tt_news.datetimeDaysToArchive = 30
>>
>>How can I check in typoscript if a record is archived or not?
>>
>>In my LIST view, I want to put "New!" in front of the titles for such
>>records.
>
>
> Sorry? I don't get the point. Usually items are archived when they are just
> the contrary of "new" ...
> AFAIK there is no "archive flag" as such. It is simply checked if the item
> is older than a given time (datetimeDaysToArchive or archive Date in the
> item itself).
> So you could check it with "if", "isGreaterThan" and then "override" - have
> a look at TSref ->stdWrap and TSref->if for the appropriate syntax.
>
> Joey
>
More information about the TYPO3-english
mailing list