[TYPO3-ttnews] Make ext:news detail view show most recent item when no id given
Loek Hilgersom
loek at netcoop.nl
Mon Sep 10 21:42:22 CEST 2012
On 10-09-12 08:50, Georg Ringer wrote:
> Hi,
>
> got a working example? wanna add it here or in the wiki? would be great
Hi Georg,
I only found time to try it out just now, so good timing
I got it working like this, but there must be a thousand ways to do this, maybe
it can be done even easier.
What I did:
Add a Typoscript setting:
plugin.tx_news.settings.detailLatest = 1
Setting this makes the list view show the detail template instead.
Add this to the Templates/News/List.html template:
<f:section name="content">
<f:if condition="{settings.detailLatest}">
<f:then>
<f:for each="{news}" as="newsItem">
<f:render partial="Detail/Item" arguments="{newsItem:newsItem,
settings:settings}"/>
</f:for>
</f:then>
<f:else>
... here goes the normal list template ...
</f:else>
</f:if>
</f:section>
Then move the entire Templates/News/Detail.html template to
Partials/Detail/Item.html and include this as a partial in
Templates/News/Detail.html
Finally, I included the plugin through Typoscript, the detail view, and the
latest detail view if no news_id is given in the URL:
[globalVar = TSFE:id = {$pages.home}]
lib.content.main < tt_content.list.20.news_pi1
lib.content.main {
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
detailLatest = 1
limit = 1
}
}
[else]
lib.content.main < styles.content.get
lib.content.main.select.where = colPos=0
[globalVar = GP:tx_news_pi1|news= ] && [globalVar = TSFE:id = {$pages.home}]
lib.content.main < tt_content.list.20.news_pi1
lib.content.main {
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
detailLatest = 1
limit = 1
}
}
[end]
It works. Not really complicated, but still, could be easier. Especially having
to use the list view for showing a detail view is a bit peculiar.
Cheers,
Loek
More information about the TYPO3-project-tt-news
mailing list