28 January, 2022 seen 671This is an article back from 2014, when I had the vision to launch a web agency in Tbilisi, Georgia. In the end, I didn…
Let's move on with our tourism companies website tutorial.
In part 1 we created a custom content type - Tours, now it's time to make a few views which will contain data from node related to content type - tours.
Before creating views - we must download a few modules, to get them work:
A bried explanation from creators of Drupal views:
- You like the default front page view, but you find you want to sort it differently.
- You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
- You use /tracker, but you want to restrict it to posts of a certain type.
- You like the idea of the 'article' module, but it doesn't display articles the way you like.
- You want a way to display a block with the 5 most recent posts of some particular type.
- You want to provide 'unread forum posts'.
- You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
- Views can do a lot more than that, but those are some of the obvious uses of Views.
If you followed tutorial part 3 - for better site administration, then you have admin menu installed. After enabling Views module, we can find path to views under Structure menu, if not, you must go to /structure/views
We gonna add new view: Tours, with page (path) and custom block:
As you can see from picture above we are filtering content type Tour. Click Continue and edit.
From picture above you can see, that I have added a block, and renamed it Featured tours - it will be the block container, which will showcase Featured tours, based on whether content is marked sticky, or not. To add such behaviour, we must add a filter - sticky:
Pay attention that I have applied this filter just for this, and not all displays.
For now save the view.
Now by accessing path /tours, we can see all tours we have entered.
In next part's I'll show how to theme views, where to put Featured tours block we just created, how to add menu items, and how to setup a custom frontpage.