Created
October 27, 2017 09:33
-
-
Save ps-team/895215fc8340181a4847dbe8f7cd43d6 to your computer and use it in GitHub Desktop.
Example of doing a basic Node Query and how to render the data it returns
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
<control name="News Listing Using Node Query" showInMenu="true" category="Dev Training" viewingGroup="1"> | |
<properties> | |
<nodeQuery name="NewsArticlesQuery" orderby="Property_DatePublished desc"> | |
<where property="Type" operator="IsEqualTo" value="News" /> | |
</nodeQuery> | |
</properties> | |
</control> | |
@using Contensis.Framework.Web; | |
@using System.Collections.ObjectModel; | |
@{ | |
ReadOnlyCollection<ContentNode> newsArticles = Properties.NewsArticlesQuery; | |
if(newsArticles.Count > 0) { | |
<ul> | |
@foreach(var newsArticle in newsArticles) | |
{ | |
DateTime publishedDate = newsArticle.PublishedDateTime; | |
string articleTitle = newsArticle.Title; | |
<li> | |
<img src="@newsArticle.ThumbnailUrl" alt="@articleTitle" /> | |
<h3><a href="@newsArticle.Path" title="@articleTitle">@articleTitle</a></h3> | |
<span>Published On: </span><time datetime="@publishedDate">@publishedDate.ToString("dd/MM/yyyy")</time> | |
<p>@newsArticle.Data.Description</p> | |
</li> | |
} | |
</ul> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment