Copied to clipboard

Flag this post as spam?

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


  • Josh Brown 4 posts 34 karma points
    Feb 09, 2021 @ 02:41
    Josh Brown
    0

    How do I show Articulate posts on my homepage?

    I have scoured Google, but all the answers seem to be from older versions of Umbraco. I want to show 4 or 5 post excerpts on my homepage. I can get results for the "ArticulateRichText" type using the query builder, but when I try to access the properties in that collection like "Excerpt" and "PublishedDate", I get error messages about IPublishedContent and other things that I don't understand.

    Here is my attempted code:

    @{
                var blog = Umbraco.Content(Guid.Parse("208fb5bd-5f50-409f-bd7d-85357a1dc707")).ChildrenOfType("ArticulateRichText").Where(x => x.IsVisible()).Take(5);
                foreach(var post in blog) {
                    <article>
                        @*<time>@post.PublishedDate.ToString("MM/dd/yy")</time>*@
                        <p><a href="@post.Url">@post.Name</a><br>
                        @*@post.Excerpt*@</p>
                    </article>
                }
            }
    

    The post URL and name work fine, but if I uncomment the date or excerpt lines, I get the following error:

    System.Web.HttpCompileException (0x80004005): C:\home\site\wwwroot\Views\Home.cshtml(91): error CS1061: 'IPublishedContent' does not contain a definition for 'PublishedDate' and no accessible extension method 'PublishedDate' accepting a first argument of type 'IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
    

    If anyone can help me solve this I would greatly appreciate it.

  • AddWeb Solution Pvt. Ltd 109 posts 360 karma points
    Feb 09, 2021 @ 08:27
    AddWeb Solution Pvt. Ltd
    100

    Hello Josh,

    Check this it can help you

    https://our.umbraco.com/packages/starter-kits/articulate/discussions/55577-Displaying-Articulate-blog-posts-on-my-homepage

    (If you tried to move blog under the home node, you need to edit the permissions on the home document type to allow children of the gallery type. You can find this in Settings > Document types > Home > permissions otherwise it will show error like "The current node is not allowed under the chosen node because of its type")

  • Josh Brown 4 posts 34 karma points
    Feb 09, 2021 @ 23:28
    Josh Brown
    0

    I saw that thread already, I have no idea which solution is the right one there. I tried the partial someone posted near the top and got "The type name 'Models' does not exist in the type 'Articulate'".

  • Josh Brown 4 posts 34 karma points
    Feb 10, 2021 @ 00:53
    Josh Brown
    0

    I was finally able to get the posts to show. Thanks for the link.

Please Sign in or register to post replies

Write your reply to:

Draft