As we learnt in Adding and editing views the views module allows you to create, manage, and display lists of content.*
These views of content can be a Block - a small lists of information that can be embedded on other pages.
We will create a block to display the subordinate taxa of a classification term, and display it on species page.
Enable views interface¶
If you haven’t already, enable the views interface:
- Go to Structure in the Admin menu, click on Tools, enable ‘Views’ and save.
Create block view¶
- Within the Admin menu, go to Structure > Views
- Select + Add new view
- Enter the view name - for example “Species subordinate taxa”
- In the Show section, select Taxonomy terms, and under Of type select the vocabulary you want to use.
- Deselect Create a page
- Select Create a block
- Enter a block title - for example “Subordinate taxa”
- Under display format, select Table
- Select Continue & edit
- Click Save to make changes permanent
Add relationship and contextual filter¶
We want to show taxa which are subordinate to the currently viewed taxon. To do this we need to add a relationship and contextual filter, so we can display terms based on their parent term.
On the edit view form, in the Relationships section click Add.
Filter the relationship types by ‘parent’, and select Taxonomy term: Parent term.
On the next screen leave the defaults (Identifier=Parent), and click Apply.
In the Contextual filters click Add.
Filter the contextual filters by ‘parent’, and select Taxonomy term: Parent term.
Under Relationship, select “Parent” (or the identifier value from Step. 6 if you did not keep the defaults)
Select Provide default value
Select Taxonomy term ID from URL
Select Save to store your changes permanently.
The view is now ready to use, but we still need to add the block to the page. We’ll see how to do this in the next section - Enabling blocks