Upload
dhruvesh-tripathi
View
121
Download
0
Embed Size (px)
Citation preview
Home >
Views
Views selects, orders and presents your content or any part/combination of it, based on the criteria you
define
Using views module, we can fetch content from the database of our site and present it to the user as lists,
posts, galleries, tables, maps, graphs, menu items, blocks, reports, forum, etc. Different content types can
also be displayed in such manners.
Views is one of the most installed modules on drupal.org
You need to install Views module for Drupal 7 and earlier, but now View is in Drupal 8 Core
Views work flow :
Choose Display
Set Format
Figure Out Fields
Apply Filter
Sort the Results
Case Study : Create a Photo Gallery using Views module
Create Content Type : To create content type, go to Structure -> Content Type -> Add Content
Type.
https://sites.google.com/a/devsadda.com/drupal-g...
1 of 12 Thursday 24 December 2015 01:17 PM
Name it as Gallery Images. Then click on Save and Manage Fields.
Now Manage Fields page will be opened.
https://sites.google.com/a/devsadda.com/drupal-g...
2 of 12 Thursday 24 December 2015 01:17 PM
Add a new field and label it as My Image.
Set field type as Image. Save the Content type.
https://sites.google.com/a/devsadda.com/drupal-g...
3 of 12 Thursday 24 December 2015 01:17 PM
Delete the Body field. We don't need it actually
Upload Dummy Contents : Go to Content, click on add content. Choose Photo Gallery.
https://sites.google.com/a/devsadda.com/drupal-g...
4 of 12 Thursday 24 December 2015 01:17 PM
Give a title and upload image. Do it 4 - 5 times.
Let's create our own image style : To create our own image style, go to Configuration -> Media ->
Image Styles. Click on Add Image style.
https://sites.google.com/a/devsadda.com/drupal-g...
5 of 12 Thursday 24 December 2015 01:17 PM
Name it as Photo Gallery, then click on create new style. New page will be opened. Under Effects
Choose Scale and Crop, then click add.
Set height and width according to your requirement, let's take it 200 x 200 for now.
https://sites.google.com/a/devsadda.com/drupal-g...
6 of 12 Thursday 24 December 2015 01:17 PM
Create view : Now let's create view. Go to Structure -> Views. Click on Add new view.
Name it as Photo Gallery. Set View settings as Content of Gallery Images sorted by Unsorted.
https://sites.google.com/a/devsadda.com/drupal-g...
7 of 12 Thursday 24 December 2015 01:17 PM
Set Display Format as Grid of Fields. Create a page and add a Menu link on Main Navigation. Click
on Save and Edit.
New page will be opened. Let's change the title as Photo Gallery. Set the format as Grids of Fields.
https://sites.google.com/a/devsadda.com/drupal-g...
8 of 12 Thursday 24 December 2015 01:17 PM
You can specify that Grid will be Horizontal or Vertical, how many images per row, etc.
Now Click on Add under Fields. Select My Image field of out Photo Gallery content type.
https://sites.google.com/a/devsadda.com/drupal-g...
9 of 12 Thursday 24 December 2015 01:17 PM
Set Image style as our Photo Gallery Image Style. You can also set the Link Image To. Let's remove
the Title Field, we don't need it actually.
Keep checking Preview.
https://sites.google.com/a/devsadda.com/drupal-g...
10 of 12 Thursday 24 December 2015 01:17 PM
Image Gallery is ready.
We can do many such things with views module. Keep Exploring!
https://sites.google.com/a/devsadda.com/drupal-g...
11 of 12 Thursday 24 December 2015 01:17 PM
https://sites.google.com/a/devsadda.com/drupal-g...
12 of 12 Thursday 24 December 2015 01:17 PM