In this video, I will show you how to create a view that will display a teaser of each of the products we created in the last video on a single page.
Create the view
- Go to "Structure => Views => Add new view" (admin/structure/views/add)
- View name: Shop
- (Optional)[x] Description: A list of products for sale (This is a field that you can use to provide additional information about the view. It is only used in the Views interface, so site visitors will not see this.)
- Show: Content
- of type: Product
- sorted by: Newest first (As we select these options, views will build the MySQL statement for us. If you’re familiar with MySQL, it will look something like: “Select * from node_table where content_type = 'Product' ORDER BY date ASC”. If you’re not familiar with MySQL, this query simply means it will retrieve all the content from the database node table with the content type of Product and sort them by date in ascending order.)
- [x] Create a page (A page represents a view that is rendered in full-page mode with its own URL. We can access a page through its URL or we can add it to one of the menus on this site)
- Path: shop (Specify the URL for accessing the view)
We will leave everything else at their default settings for now. So, we'll get an unformatted list of content teasers with links (to comment and view more) but without comments. We'll show 10 per page, and show a pager.
- (Save & Exit)
Now we have our first view! Right now, we have a page that displays products in an unformatted list of teasers. If you click "Read more" you'll see the full-node page with the image, availability, price and description. Now, at this point, we could configure the Teaser display to include the image and other fields, but since this is a Views series, in the next video, we are going to take a look at how we can use Views to select which fields of the content type we'd like to display without having to click the "Read more" link.