In this exercise we will try out all the possibilities within the view core module. Views has many more extension modules, but this is for later. Some reference knowlegdge is neede for this exercise as we are comining two content types. Views and references are in the core so you don't have to install anything.
We handle the following subjects:
In the core:
- entity reference
Display content in
- formatted list
- unformatted list
- Show filters in a block
- Header and footer
- When there is no content
- Contextual filters
Make 2 content types who are related to eachother. EG Painters and paintings. Each content type has a body and image field. The paintings are linked with a content reference towards the painters. I have 2 painters: Gustav Klimt and Pablo Picasso. Each with 2 paintings. (source Wikipedia)
Make a view with a page where the paintings are beiing shown. Try out the possibilities.
Table with fields:
The field structure
You can set the rights:
Rewriting the results combining 2 fields and adding some CSS class. Use tokens to do so.
Now we want the picure from the painter as well. It is in the other content type! So we can not access it directly. Mak a relation first and then you can add the field.
Use the relation in the field configuration:
With the configuration of the table you can put content in the same column. An example:
Probeer eens de groepering uit.
Head and footer of a view:
What if there are no results? Add a message.
Table headers can be sticky and stay always at the top of your view.
Sometimes when working with relations, you can get dubble output. Setting the distinct option you avoid this problem.
Put all the filters in one block.
A contextual filter, filters with the URL. This is important and it has many advantages in combination with soma other view modules as Viewfield and EVA (entity view attachment). Now i don't want to use external view modules, so relax... I only show the way of filtering.
You see nothing unless you fill in the name of the painter.
In the URL you can see the painter and below the filtering.
Aggregation is beiing used for counting, averages,.... Make a attachment view and counts how many paintings we have in the content type. Add this below the view of the paintings.