Created
October 27, 2017 10:01
-
-
Save ps-team/248cda885b9d619e9b922824acfd2263 to your computer and use it in GitHub Desktop.
News mini list with dates in razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Contensis.Framework.Web | |
@using Contensis.Framework.Web.Search | |
@{ | |
var newsArticlesQuery = Query.Where("SC_T_ID").IsEqualTo("-1025").OrderBy("Property_DatePublished").Descending; /* add template id for news here */ | |
var newsArticles = new NodeFinder().Find(newsArticlesQuery, selectCount:3); | |
var utils = new CMS_API.Common.BaseUtilities(); | |
} | |
<div class="sys_miniList sys_miniListNews"> | |
<h2>Latest <span>News</span></h2> | |
@foreach(var newsArticle in newsArticles) | |
{ | |
var description = @newsArticle.Data.Description.ToString(); | |
<div class="sys_miniListItem"> | |
<h3><a href="@newsArticle.Path" title="@newsArticle.Title">@newsArticle.Title</a></h3> <span class="sys_miniListDate">- @newsArticle.Data.Property_DatePublished.ToString("d/M/yyyy") </span> | |
<p class="sys_miniListDescription">@description.Substring(0, 50)… <a href="@newsArticle.Path" title="@newsArticle.Title" class="sys_miniListLink">[+]</a></p> | |
</div> | |
} | |
<a href="/en/WorldHeritageSite/PressArea/NewsListing.aspx" class="sys_miniListLink">See all News</a> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment