-
Notifications
You must be signed in to change notification settings - Fork 3
Removing thumbnails from University News Block
Rob Knight edited this page Sep 20, 2021
·
5 revisions
Modified code removing thumbnails from homepage news and set limit to 4
## Get articles for an index block
#set ($articlesLimit = 4)
#set ($articles = $_XPathTool.selectNodes($contentRoot,"//system-page[not(contains(path,'_internal'))][not(@current)][not(system-data-structure/page-type = 'Category Index')][dynamic-metadata[starts-with(name,'category-')]/value = ancestor::system-index-block/calling-page/system-page/dynamic-metadata[starts-with(name,'category-')]/value]"))
#if (!$articles.isEmpty())
## Sort articles by start-date, then article-date
$_SortTool.addSortCriterion("dynamic-metadata[name='type']/value","","text","descending","upper-first")
$_SortTool.addSortCriterion("start-date","","number","descending","upper-first")
$_SortTool.sort($articles)
<div id="news" class="block news-block">
<h3 class="block-header"><a class="headline" href="http://news.ucsc.edu">University <span>News</span></a></h3>
<ul class="archive-list">
#if ($articles.size() <= $articlesLimit )
#set ($articlesToList = $articles)
#else
#set ($articlesToList = $articles.subList(0,$articlesLimit) )
#end
#foreach($page in $articlesToList)
## Get/set vars
#set ($title = $_SerializerTool.serialize($page.getChild("title"),true).replaceAll('"', '"'))
#set ($path = $page.getChild("link").value)
#set ($dateNode = $page.getChild("start-date"))
#set ($pageDate = $_DateTool.getDate($dateNode.value))
#set ($pageDateText = $_DateTool.format('MMMM d, yyyy',$pageDate))
<li>
<a href="${path}">
<span class="date">${pageDateText}</span>
<span class="headline">${title}</span>
</a>
</li>
## Reset img path for next article
#set ($imgLink = "")
#end
</ul>
<p class="more"><a href="http://news.ucsc.edu">More news</a></p>
</div>
#end