Utilizing dynamic arguments
Views can be configured to accept contextual filters. Contextual filters allow you to provide a dynamic argument that modifies the view's output. The value is expected to be passed from the URL; however, if it is not present, there are ways to provide a default value.
In this recipe, we will create a new page called My Content
, which will display a user's authored content on the /user/%/content
route.
How to do it...
- Go to
Structure
and thenViews
. This will bring you to the administrative overview of all the views created. Click onAdd view
to create a new view. - Set the
View name
toMy Content
. - Next, we will modify the
View
settings. We want to displayContent of the type All
and leave theTagged
with empty. This will allow all content to be displayed.
Â
- Select
Create
a page
. Keep the page title the same. We will need to change the path touser/%user/content
. Click onSave and edit
to move to the next screen and add the contextual filter.
Note
When building a views page...