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.
Problem:
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"?
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.
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.
Problem:
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.
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.
is working on a reply...