Tags are convenient for categorizing blogposts by the topics they cover. Offering the tags as filters makes it easy for visitors to choose a topic they are interested in.
To achieve this, we're going to render a small tag cloud on the overview page. If one of the tags is clicked, we want it to be passed to the controller. We'll do this via the “tag” parameter. This way, we can filter the BlogPostPage instances by the given tag.
We already have the
tags attribute to work with in our
BlogPostPage model definition. In this attribute the tags of each blog post are stored. So, in our
BlogOverviewPageController, if a tag was passed to it, we can search for posts whose
tags attribute contains this tag. Go ahead and change the controller to: