CMS
Week 8
Basic Views
What are views?
Views?
A view is a listing of content on a website.
The core Views module handles the display of views, and the core Views UI module allows you to create and edit them in the administrative interface.
When you define views, you are interested in taking data from your website and displaying it to the user.
Views?
Using the Views module, you can fetch content from the database of your site and present it to the user as lists, posts, galleries, tables, maps, graphs, menu items, blocks, reports, forum posts, etc.
Different content types including nodes, users, and other bundles can be displayed.
Types of view
Pages
- Have their own /path-url
Blocks
- Are placed through /stucture/blocks
(There's more!)
Settings


UI

How to
How to
Let's create a new View to display all of our cars.
We will create a Page view to display all of our cars in Teaser form on the url /cars
How to: Page view
- Go to /admin/structure/views
- Click Add view
- Enter a name: Cars
- Set Show content to Cars
- Click Create a page
- Set Display format to Unformatted list of Teaser
- Set Items to display to 20
- Click Create a menu link
- Set Menu to Main navigation
- Hit Save and edit
How to: Page view
- You can now go visit your new view over at /cars
- You will probably want to change the order/display of your car teasers
- Go to /admin/structure/types/manage/car/display/teaser
- Re-arrange/Change display options
How to
Now that we have a page showing teasers on /cars, we want to add a small list to our homepage showing the latest entries.
For this we will create a new block-view.
How to: Block view
- Go to /admin/structure/views
- Find the view Cars and hit Edit
- Under displays, click Add -> Block
- Set block name: Latest cars
- Change pager options:
- For: This block (override)*
- Use pager: Display a specified number of items
- Set items to 5
- Hit Save
*IMPORTANT
How to: Block view
- Go to /admin/structure/block
- On Content hit Place block
- Find your new Cars block and hit Place
- Uncheck Show page title
- Set page restriction to: show on <front> only
- Hit Save
The new block is now available on the home page.
Opt.: How to: Block view
-
You can add row/column classes through the UI
- Next to Format:Unformatted list, hit Settings
- Set row class: 'col-md-6', 'col-sm-12', etc
-
Under Advanced
-
CSS class
- Enter 'row'
-
CSS class
CMS W8 18-19
By Pieter Mathys
CMS W8 18-19
Basic views
- 778