Partial view to display list of objects on every page
First of all I'd like to say - I'm new to Umbraco.
I watched instructional videos, read docuemntation but still can't figure this one out.
So I have a Person object with some basic properties - name, image, title etc.
There will be a page for each person. And also I'd like to display a gallery of persons on every other page - Home, about, etc.
If I'm building pure MVC site I'll create a partial view with a controller that will use IPersonService to get all that data from DB for example. And in my partial view I'll use something like this as a model:
public class PersonListViewModel
{
public IEnumerable<Person> { get; set; }
}
Partial view to display list of objects on every page
First of all I'd like to say - I'm new to Umbraco. I watched instructional videos, read docuemntation but still can't figure this one out.
So I have a Person object with some basic properties - name, image, title etc. There will be a page for each person. And also I'd like to display a gallery of persons on every other page - Home, about, etc.
If I'm building pure MVC site I'll create a partial view with a controller that will use IPersonService to get all that data from DB for example. And in my partial view I'll use something like this as a model:
How to do this "the Umbraco way"?
Thanks V.
When you say that there will be a page, do you mean a node in Umbraco? If yes, then what you can do is:
For the person page In the pages template simply display properties from Umbraco (using for example Model.Content.GetPropertyValue("name")).
For the gallery of persons
On the gallery template make a call to your controller.
Create a controller that gets the list of person objects from Umbraco (using content service https://our.umbraco.org/documentation/reference/management/services/contentservice).
The controller should return a partial view with the list as a model.
In your partial view declare the model and iterate through the list of persons displaying the properties you would like to show.
Ex.
is working on a reply...