I wanted to make a list of “related nodes” based on the term that is attached to the node.
Say I have 10 nodes that have the term “fruit”. With every fruit-node I want to display 5 links to other fruit-nodes.
I work with panels and views.
This turned out more time-consuming then I thought because the way to do it is not straight forward.
- Make a new view
- Add “taxonomy term id” as argument. Select “hide view” is the argument isn’t provided.
- Add a couple of fields to display (eg: title, teaser).
- Save the view. Make sure your caches are cleared.
- Make or edit a page (with the panels module through: Administer › Site building › Pages).
- Make or edit a variant.
- We need to add a new relationship to the variant. This will make it possible to parse the term id to the view.
- Click on the tab “context” in the variant.
- Add a relationship. Select “Term from node” in the dropdown and click the “Add relationship” button.
- A new window will open. Select the correct vocabulary (in my example: the vocabulary where “fruit” belongs to). You might want to give it a decent name so you can recognise it later.
- Click “ok”.
- In the “content” tab, add a new pane to the panel. (click the gear icon and select “add content”)
- Select the view you’ve just created (under the “views” tab on the right) and select the “default” view. (do not make a “content pane” in the view because this does not work that way).
- Normally it will show the views’ argument (term id) with a dropdown under it. In the dropdown select the term id of the relationship we created in Step 7.
- Click update & save. This should do.