Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Amr Younis 13 posts 94 karma points
    Oct 26, 2016 @ 19:27
    Amr Younis
    0

    '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

    @{

    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

    enter image description here

    thanks Amr

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Nov 14, 2016 @ 17:57
    Alex Skrypnyk
    0

    Hi Amr,

    It looks like you have to fix this issue in LatestArticles partial.

    Can you share code of LatestArticles file?

    Thanks,

    Alex

  • Amr Younis 13 posts 94 karma points
    Dec 01, 2016 @ 10:52
    Amr Younis
    1

    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>
     }
    
  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Dec 01, 2016 @ 11:09
    Alex Skrypnyk
    0

    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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies