Copied to clipboard

Flag this post as spam?

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

  • denis ushakov 11 posts 144 karma points
    Mar 05, 2019 @ 23:26
    denis ushakov

    Display posts from specific category on a single blog post

    Is there a way to display blogs (created using List.cshtml) on a single blog page (created using Post.cshtml)? I am having issues making it work.

    Some context:
    After I created a blog post (adding content, images and category) I am trying to display a list of blogs that are in the same category (or few most recent blogs) at the bottom of this newly created page.

    List.cshtml uses @model Articulate.Models.ListModel
    Post.cshtml uses @model Articulate.Models.PostModel
    This clearly causes an issue when trying to combine the functionality of both views together as they are using different models.

    Has anyone encountered the same issue or should i say "the same need for this functionality"?

    Any suggestions, answers or ideas will help.

  • Shannon Deminick 1498 posts 5073 karma points hq
    Mar 06, 2019 @ 06:29
    Shannon Deminick

    You can pass in any model you want to a partial view so if you are using List.cshtml as a partial view from your Post.cshtml you can create a ListModel and pass it along, Otherwise it's probably better to create a custom partial view that you have full control of, another option is to use a Child Action which might be easiest since you can avoid data lookup in your views.

Please Sign in or register to post replies

Write your reply to: