public ActionResult RenderBlog() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("blogPreviewTitle"); string introduction = homePage.GetPropertyValue("blogPreviewIntro").ToString(); BlogPreview model = new BlogPreview(title, introduction); return(PartialView(PartialViewPath("_Blog"), model)); }
public ActionResult RenderPostList(int numberOfItems, bool horizontalLayout = false) { List <BlogItem> blogItems = new List <BlogItem>(); IPublishedContent homePage = Umbraco.TypedContentAtRoot().First(); IPublishedContent blogPage = homePage.Children.FirstOrDefault(x => x.DocumentTypeAlias == "blog"); foreach (IPublishedContent page in blogPage.Children.Where(x => x.DocumentTypeAlias == "blogPost").OrderByDescending(x => x.UpdateDate).Take(numberOfItems)) { blogItems.Add(new BlogItem(page.GetPropertyValue <string>("largeHeading"), page.GetPropertyValue <string>("articleCategory"), page.GetPropertyValue <string>("articleIntro"), page.GetPropertyValue <DateTime>("atriclePublishDate"), page.Url)); } BlogPreview model = new BlogPreview(blogItems, horizontalLayout); return(PartialView(PartialViewPath("_PostList"), model)); }
// GET: Blog public ActionResult Index() { return(View(BlogPreview.GetList())); }