Last active
December 7, 2016 08:32
-
-
Save emmanueltissera/d7eacf43adb0eb9180ff5064ec60777e to your computer and use it in GitHub Desktop.
EmmTi.KenticoCloudConsumer.EnhancedDeliver Quick Setup
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
@model EmmTi.KenticoCloudConsumer.EnhancedDeliver.Sample.Models.SampleViewModel | |
<div class="article-tile article-tile-large"> | |
<div class="col-md-12 col-lg-6"> | |
<a href="@Url.Action("Show", "Articles", new { id = Model.System.Codename })"> | |
<img src="@Model.TeaserImage.Url" class="article-tile-image" alt="@Model.System.Name" /> | |
</a> | |
</div> | |
<div class="col-md-12 col-lg-6"> | |
<div class="article-tile-date"> | |
@Model.PostDate.ToString("m") | |
</div> | |
<div class="article-tile-content"> | |
<h2> | |
<a href="@Url.Action("Show", "Articles", new { id = Model.System.Codename })">@Model.System.Name</a> | |
</h2> | |
<p class="article-tile-text lead-paragraph"> | |
@Model.Summary | |
</p> | |
</div> | |
</div> | |
</div> |
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
PM > Install-Package EmmTi.KenticoCloudConsumer.EnhancedDeliver |
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 EmmTi.KenticoCloudConsumer.EnhancedDeliver.Sample.Models; | |
using EmmTi.KenticoCloudConsumer.EnhancedDeliver.Factories; | |
using System.Threading.Tasks; | |
using System.Web.Mvc; | |
namespace EmmTi.KenticoCloudConsumer.EnhancedDeliver.Sample.Controllers | |
{ | |
public class SampleController : AsyncController | |
{ | |
[Route] | |
public async Task<ActionResult> Index() | |
{ | |
var response = await DeliverClientFactory<SampleViewModel>.GetItemAsync(SampleViewModel.ItemCodeName); | |
return View(response); | |
} | |
} | |
} |
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 EmmTi.KenticoCloudConsumer.EnhancedDeliver.Helpers; | |
using KenticoCloud.Deliver; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
namespace EmmTi.KenticoCloudConsumer.EnhancedDeliver.Sample.Models | |
{ | |
public class SampleViewModel : BaseContentItemViewModel | |
{ | |
public const string ItemCodeName = "article"; | |
public HtmlString BodyCopy { get; set; } | |
public string MetaDescription { get; set; } | |
public string MetaKeywords { get; set; } | |
public Dictionary<string, string> Personas { get; set; } | |
public DateTime PostDate { get; set; } | |
public List<SampleViewModel> RelatedArticles { get; set; } | |
public string Summary { get; set; } | |
public Asset TeaserImage { get; set; } | |
public string Title { get; set; } | |
protected override void MapContentForType(ContentItem content, int currentDepth) | |
{ | |
BodyCopy = new HtmlString(content.GetString("body_copy")); | |
MetaDescription = content.GetString("meta_description"); | |
MetaKeywords = content.GetString("meta_keywords"); | |
Personas = content.GetTaxonomyItems("personas"); | |
PostDate = content.GetDateTime("post_date"); | |
RelatedArticles = content.GetModularContent("related_articles").GetListOfModularContent<SampleViewModel>(currentDepth + 1); | |
Summary = content.GetString("summary"); | |
TeaserImage = content.GetAssets("teaser_image").FirstOrDefault(); | |
Title = content.GetString("title"); | |
} | |
} | |
} |
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
<add key="DeliveryContentCacheTimeSeconds" value="300"/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment