DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
Simple snippets¶
This section contains snippets making EXT:news more awesome which might be useful for your projects as well.
Improved back links¶
The back link on a detail page is a fixed link to a given page. However it might be that you use multiple list views and want to change the link depending on the given list view.
A nice solution would be to use this JavaScript jQuery snippet:
if ($(".news-backlink-wrap a").length > 0) {
if(document.referrer.indexOf(window.location.hostname) != -1) {
$(".news-backlink-wrap a").attr("href","javascript:history.back();").text('Back');
}
}
Creating links with fluid¶
Besides the ViewHelper <n:link />
you can also use the ViewHelpers of fluid itself:
<f:link.page pageUid="13" additionalParams="{tx_news_pi1: {controller: 'News',action: 'detail', news:newsItem.uid}}">{newsItem.title}</f:link.page>
<a href="{f:uri.page(pageUid:13,additionalParams:'{tx_news_pi1:{controller:\'News\',action:\'detail\',news:newsItem.uid}}')}">{newsItem.title}</a>
Set n:link target page in fluid¶
If the detail page should not be set in the plugin or by a category, it can also be set within the template:
<n:link
newsItem="{newsItem}"
configuration=“{parameter:settings.somePid}"
settings="{settings}" title="{newsItem.title}"><f:translate key="more-link"/></n:link>
The setting settings.somePid can e.g. set with plugin.tx_news.settings.somePid=123.
Render category rootline¶
If you want to show not only the title of a single category which is related to the news item but the complete category rootline use this snippets.
<f:if condition="{category:newsItem.firstCategory}">
<ul class="category-breadcrumb">
<f:render section="categoryBreadcrumb" arguments="{category:newsItem.firstCategory}" />
</ul>
</f:if>
and
<f:section name="categoryBreadcrumb">
<f:if condition="{category}">
<f:if condition="{category.parentCategory}">
<f:render section="categoryBreadcrumb" arguments="{category:category.parentCategory}" />
</f:if>
<li>{category.title}</li>
</f:if>
</f:section>
Use current content element in the template¶
If you ever need information from the content element itself, you can use {contentObjectData.header}
.
Use current page in the template¶
If you ever need information from the current page, you can use {pageData.uid}
.