I am using a node to represent a subsite on my website. The node has just two fields: title
and field_subsite
. The titles are all listed on the front page.
The subsites are constructed using a View: I.e.: Each leaf node has a taxonomy field, which hold the subsite identifier. I use a contextual filter in a page View that picks up the subsite identifier to display a page with all the nodes that belongs to a particular subsite. For example: example.com/subsite/1
shows all the nodes belonging to subsite with taxonomy term 1. All this works fine.
However, the missing bit is that when the user clicks on the title on the front page that identifies a subsite, they are taking to the node with the subsite identifier exposed. They have to click on this to see the actual subsite with taxonomy term 1.
Is there a way to set this up so that when clicking on title, the user is taken directly to the subsite represented by that title.
So far, all this has been created in the UI, but I guess that I should be able to solve this by implementing hook_node_view()
and redirecting to the view from there?
However, I would like to know is there is a better solution.
example.com/subsite/1
). Added this extra information to the question. If I do it with a block view (in order to use core's Layout Builder), how to I get the TID passed to the View?