12
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

Views (Basic)

Embed Size (px)

Citation preview

Page 1: Views (Basic)

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

Page 2: Views (Basic)

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

Page 3: Views (Basic)

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

Page 4: Views (Basic)

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

Page 5: Views (Basic)

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

Page 6: Views (Basic)

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

Page 7: Views (Basic)

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

Page 8: Views (Basic)

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

Page 9: Views (Basic)

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

Page 10: Views (Basic)

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

Page 11: Views (Basic)

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

Page 12: Views (Basic)

https://sites.google.com/a/devsadda.com/drupal-g...

12 of 12 Thursday 24 December 2015 01:17 PM