Created
September 23, 2014 08:56
-
-
Save contensis/5bb0779642918cf8852b to your computer and use it in GitHub Desktop.
Load Structured Content Image
This file contains 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
Dim imageNode As Node = GetNodeByContentId(imageContentId) | |
@If imageNode IsNot Nothing Then | |
@<div class="sys_article-image"><img src="@imageNode.FullPath" alt="@imageNode.Title" /></div> | |
End If | |
@Functions | |
Function GetNodeByContentId(contentId As Integer) As Node | |
Dim myQuery = Query.Where("Property_C_ID").IsEqualTo(contentId) | |
Dim nodes = New NodeFinder().Find(myQuery, 1, selectCount:=1) | |
If nodes.Count > 0 Then | |
Return nodes(0) | |
Else | |
Return Nothing | |
End If | |
End Function | |
End Functions |
This file contains 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("-137").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(); | |
} | |
@foreach(var newsArticle in newsArticles) | |
{ | |
var imageContentId = newsArticle.Data.articleimagecontentid; | |
if(newsArticle.Data.Property_TaxonomyCategories.ToString() != ""){ | |
var newsCategory = CurrentContext.Taxonomy.GetByKey(newsArticle.Data.Property_TaxonomyCategories.ToString().Replace(",","")); | |
<p>@newsCategory.Value</p> | |
} | |
<p><a href="@newsArticle.Path" title="@newsArticle.Title">@newsArticle.Title</a></p> | |
<p class="sys_miniListDescription">@newsArticle.Data.Description</p> | |
if (imageContentId != null) | |
{ | |
var imageNode = GetNodeByContentId(imageContentId.ToString()); | |
<div class="sys_article-image"><img src="@imageNode.FullPath" alt="@imageNode.Title" /></div> | |
} | |
} | |
@functions | |
{ | |
public Node GetNodeByContentId(string contentId) | |
{ | |
var myQuery = Query.Where("Property_C_ID").IsEqualTo(contentId); | |
var nodes = new NodeFinder().Find(myQuery); | |
if (nodes.Count > 0) { | |
return nodes[0]; | |
} else { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment