Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Dear All,
I have a problem when i try to get latest post on my home page so if any one can help this will be grate this is my code below
Partial View
@using Articulate
@using Umbraco.Web
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
var root = Model.AncestorOrSelf(1); var blogRoot = root.Children; var blogArchive = root.Children.First(); if (!blogArchive.Children.Any()) { <p>No blog posts found</p> } else { string strLastClass = ""; <ul class="recent_blogs"> @foreach (var post in blogArchive.Children) { if (post.IsLast()) { strLastClass = "last"; } <li class="@strLastClass"> <h3><a href="@post.Url">@post.Name</a></h3> <p>@post.GetPropertyValue("Excerpt")</p> </li> } </ul> }}
Master Page
@Html.Partial("LatestArticles")
and i get this error
thanks Amr
Hi Amr,
It looks like you have to fix this issue in LatestArticles partial.
Can you share code of LatestArticles file?
Thanks,
Alex
Hi Alex
First Thanks for replay,I a ready fix this issue and this my Code
@using Articulate @inherits Umbraco.Web.Mvc.UmbracoViewPage @{ var blogRoot = Umbraco.ContentAtRoot().DescendantsOrSelf("Articulate").FirstOrDefault(); var blogArchive = blogRoot.Children.FirstOrDefault(); } @if (blogArchive != null && blogArchive.Children.Any()) { <section class="postes paddingspace"> <div class="container"> <div class="title"> <h1>أحدث المقالات</h1> </div><!--title--> <div class="row"> @foreach (var post in blogArchive.Children) { var thumbnail = post.GetCropUrl("postImage", "blogPost"); string result = post.Excerpt; if (result.Length > 100) { result = result.Substring(0, 100) + "..."; } <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12"> <div class="post-area"> <div class="post-img"> <a href="@post.Url"> <img src="@thumbnail" alt="@post.Name" onerror="this.src = '/content/img/no_image.gif';" /> </a> </div><!--post-img--> <div class="post-title" style="text-align:center"> <h3> <a href="@post.Url"> @post.Name </a> </h3> </div><!--post-title--> <article> @Html.Raw(result) </article> </div> </div> } </div> </div> </section> }
Hi Amr
Glad that you found a solution.
Be aware of DescendantsOrSelf method, it can slow down performance if you have a lot of nodes.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
'Models' does not exist in the type 'Umbraco.Web.PublishedContentModels.Articulate'
Dear All,
I have a problem when i try to get latest post on my home page so if any one can help this will be grate this is my code below
Partial View
@using Articulate
@using Umbraco.Web
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
Master Page
@Html.Partial("LatestArticles")
and i get this error
thanks Amr
Hi Amr,
It looks like you have to fix this issue in LatestArticles partial.
Can you share code of LatestArticles file?
Thanks,
Alex
Hi Alex
First Thanks for replay,I a ready fix this issue and this my Code
Hi Amr
Glad that you found a solution.
Be aware of DescendantsOrSelf method, it can slow down performance if you have a lot of nodes.
Thanks,
Alex
is working on a reply...