views unlimited: unleashing the power of drupal's views module

72
V Engr. Ranel O. Padon Drupal Apprentice Training https://github.com/ranelpadon UNLIMITED IEWS

Upload: engr-ranel-padon

Post on 08-Sep-2014

518 views

Category:

Technology


0 download

DESCRIPTION

Unleashing the power of Views Drupal module. Discusses Display Formats (Map, Chart, Slideshow, Data Export), Fields, Basic Filters, Exposed Filters, Contextual Filters, Relationships, Attachment, and so on. Includes numerous sample use cases and recommendations.

TRANSCRIPT

Page 1: Views Unlimited: Unleashing the Power of Drupal's Views Module

VEngr. Ranel O. Padon

Drupal Apprentice Training

https://github.com/ranelpadon

UNLIMITEDIEWS

Page 2: Views Unlimited: Unleashing the Power of Drupal's Views Module

TOPICS

Introduction

Views Components

Formats

Fields

Basic Filters, Exposed Filters, Contextual Filters

Relationships

Attachment

Display Formats: Map, Chart, Slideshow, Data Export

Recommendations

Page 3: Views Unlimited: Unleashing the Power of Drupal's Views Module

About Me

Full-time Drupal developer for CNN Travel

Part-time Python/Web GIS lecturer in UP.

Involved in computational Java and Python projects before.

Plays competitive football and futsal.

Page 4: Views Unlimited: Unleashing the Power of Drupal's Views Module

INTRODUCTION

“Views changed my life.”

~Michelle Lauer and Greg Stout

Page 5: Views Unlimited: Unleashing the Power of Drupal's Views Module

INTRODUCTION

The No.1 module out of 27,000+ modules.

Page 6: Views Unlimited: Unleashing the Power of Drupal's Views Module

INTRODUCTION

Earl Miles: the Views creator.

Drupal.org: @merlinofchaos

Page 7: Views Unlimited: Unleashing the Power of Drupal's Views Module

INTRODUCTION

Page 8: Views Unlimited: Unleashing the Power of Drupal's Views Module

INTRODUCTION

Views is a module that displays a list of data.

One set of data could have many Views. #flexibility

Page 9: Views Unlimited: Unleashing the Power of Drupal's Views Module

Under the Hood

Page 10: Views Unlimited: Unleashing the Power of Drupal's Views Module

Under the Hood

Page 11: Views Unlimited: Unleashing the Power of Drupal's Views Module

Under the Hood

Page 12: Views Unlimited: Unleashing the Power of Drupal's Views Module

Under the Hood

Page 13: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

Views is essentially a view of data.

For example, if you’re in a bar with your friend (which could be drunk

already), and suddenly a woman entered the room your friend may find

the woman gorgeous/sexy, but you might find it just mediocre/ugly.

Page 14: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

In that case, there are 2 dif ferent Views or perspective: your View and

your friend’s View; while the data (the Woman) is the same for both of

you, it could be portrayed differently.

Page 15: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

In the same way, Views retrieve data from the database, selects the

content types you want (Blog, News, Product, Tourist Spot), the

f ields you want (Title, Images, Author, Location, Price), f i lter them

(filter by category, filter by price), apply some pre-processing

(compute total, aggregate data), sort them (sort by surname, sort by

area, sort by publication date), and finally display them in a format you

want (list, grid, charts, maps, gallery).

Page 16: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

Hence, a same pool of data could be combined and viewed in many

ways. This makes Drupal really powerful!

Page 17: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

Views is the make or break of Drupal. Many people find it to be

intimidating and hard. But essentially, it just answers these 3 questions:

What?

Where?

How?

Page 18: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views Demystified

What (Content Type, Fields)

Where (Page, Block, Attachment)

How (List, Table, Gallery, Chart, Map)

Page 19: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Let's Get Our Hands Dirty!

Enable: Chaos Tools, Views, and Views UI modules

Create 3 Articles (fill-in their Title, Body, and Tags fields)

Page 20: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST

Page 21: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST

Page 22: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST

Page 23: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | DISPLAY

Edit View.

Set Display to HTML List.

Save View.

Edit View.

Set Display to Grid and Table.

Utilize the Views' Preview section.

Utilizing the “?” help/hint icons

- if the Advanced Help module is installed

Page 24: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | SORTING

Remove the Post Date sorter.

Add Title Sorter, Set to Ascending.

Check Preview.

Page 25: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | FIELDS

Change Display's Contents to Fields.

Add fields.

Rearrange fields.

Remove fields.

Trim Fields (trim the Body field to 20 characters only).

Page 26: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | EXPOSED FILTERS

Add exposed filter (filter by Tags)

Enable AJAX (to avoid page reloading)

Page 27: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: PATH, PERMISSION, PAGERS

Edit Path.

Add Menu Link.

Control the Permission.

Add a Footer message.

Paged Output

Full vs Mini Pager

Exposed Pager

Page 28: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | BLOCK VIEW

Add a new View in the current View

Set the Display Name

Display the view in Block.

'All Displays' vs 'This Block (Override)'

Show Titles Only

Enable the Block

Show that Block in that page only.

Page 29: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: SIMPLE LIST | PAGE CLONING

Clone a Page

Set the Display Name

Display All contents (don't set the edit to All Displays!)

Edit Path (/articles-full)

Connect the Block to the new Page

Set the More Link (Display 2 contents only) in the Block

Advanced >> Link Display: check Full Articles Page

Page 30: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: CLONING | TABBED MENUS

Clone the Articles Views in admin/structure/views

Set the Page View's Path as /articles-parent

Clone the parent Page, Re-order Views Displays

Set Path as /articles-parent/tab1

Menu Settings:

Title: Tab 1

Type: Default Menu Tab

Parent Menu Item: Normal Menu Item

Menu: Main Menu

Page 31: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: CLONING | TABBED MENUS

Page 32: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: CLONING | TABBED MENUS

Go to the other Page Display

Set Path as /articles-parent/tab2

Menu Settings:

Title: Tab 2

Type: Menu Tab

Menu: Main Menu

Weight: 1

Page 33: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: CLONING | TABBED MENUS

For easier and more powerful tabbing needs,

See the Quick Tabs module:

https://www.drupal.org/project/quicktabs

Page 34: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Destination with Reviews

Relationships between Tourist Spot and Review content types.

The Review's table has been merged to the Tourist Spot's table to

connect and retrieve information.

Page 35: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

For merging information across tables. In SQL, it's the JOIN operation.

Usually used if you want to access deeper information from two or

more content types, including users or taxonomy terms' comprehensive

object/table information.

Activate these modules for this exercise:

Entity API

Entity Reference

Inline Entity Form

Page 36: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Create Review content type

Title field: Byline

Reviewer: Text

Rating: List (Integer)

Create Tourist Spot content type

Destination Name: Text

Review: Entity Reference

Widget: Inline Entity Form

Page 37: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Create Review content type

Page 38: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Create Tourist Spot content type

Page 39: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

*Create 3 Tourist Spots

1. Tourist Spot:

Name: Amanpulo Beach Resort

Review:

Byline: Excellent Service!!

Reviewer: Juday

Rating: 5

Page 40: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

*Create 3 Tourist Spots

2. Tourist Spot:

Name: Taal Volcano

Review:

Byline: Good View

Reviewer: PNoy

Rating: 4

Page 41: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

*Create 3 Tourist Spots

3. Tourist Spot:

Name: Chocolate Hills

Review:

Byline: Disappointed!

Reviewer: Mommy D

Rating: 2

Page 42: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Create new View

Page 43: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Add the Relationships

Page 44: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Relationships

Adjust the Fields

Page 45: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Contextual Filters

Usually used for creating related contents/block/info for each individual

page.

Page 46: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Contextual Filters

Add a new Block display, then set the Nid as a contextual filter

(Arguments in Drupal 6)

Page 47: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

We need fields for holding

location information.

These field will be used by Views

for displaying contents in a map.

Page 48: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Activate Modules:

Libraries

GeoPHP, Geofield

Leaflet, Leaflet Views, Leaflet More Maps

Put the "leaflet" JS library in sites/all/libraries,

so that you will have site/all/libraries/leaflet/leaflet.js file

Page 49: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Add an Is land Group Taxonomy Vocabulary, then add the Luzon,

Visayas, and Mindanao terms.

Page 50: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Add Location field and Island Group field in Tourist Spot

Page 51: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Edit each Tourist Spot, and specify the values:

Amanpulo Beach Resort

Latitude: 11

Longitude: 121

Island Group: Luzon

Page 52: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Edit each Tourist Spot, and specify the values:

Taal Volcano

Latitude: 14

Longitude: 121

Island Group: Luzon

Page 53: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Edit each Tourist Spot, and specify the values:

Chocolate Hills

Latitude: 9.8

Longitude: 124.2

Island Group: Visayas

Page 54: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Map Display

Add Location field and Island Group field in Tourist Spot

Page 55: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: OpenLayers

Implement a similar view using the OpenLayers module.

https://www.drupal.org/project/openlayers

Follow this guideline:

https://www.drupal.org/node/1481374

For a comprehensive discussion of mapping with Drupal:

http://www.slideshare.net/ranelpadon/of-nodes-and-maps

Page 56: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Chart Display

We need a charting library

to visualize Views data.

Charts utilizes the

Views' Aggregation

and Count operations.

Page 57: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Chart Display

Activate Modules:

Libraries

Visualization

Put the "highcharts" JS library in sites/all/libraries,

so that you will have site/all/libraries/highcharts/js/highcharts.js file

Page 58: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Chart Display

Page 59: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Google Chart Tools

Implement a similar view using the Views Chart Tools module.

https://www.drupal.org/project/views_chart_tools

Follow this guideline:

https://www.drupal.org/node/1675788

Page 60: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Slideshow Display

We need an slideshow plugin for

cycling the contents/fields

Page 61: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Slideshow Display

Activate Modules:

Libraries

Views Slideshow, Views Slideshow Cycle

Put the "jquery.cycle" JS library in sites/all/libraries,

so that you will have a

site/all/libraries/jquery.cycle/jquery.cycle.all.min.js

Page 62: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Slideshow Display

Add a Photos field, then upload the 3 sample photos provided for each

Tourist Spot.

Page 63: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Slideshow Display

Page 64: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Flex Slider

Try also the responsive and nifty FlexSlider module:

https://www.drupal.org/project/flexslider

Page 65: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Export Data as csv, xls, etc

Activate Module:

Views Data Export

Page 66: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Export Data as csv, xls, etc

Essential idea:

1. Set the Display Format to XLS, CSV, etc.

2. Set the export Path.

3. Set the view that it will be attached to.

Page 67: Views Unlimited: Unleashing the Power of Drupal's Views Module

Views: Export Data as csv, xls, etc

Page 68: Views Unlimited: Unleashing the Power of Drupal's Views Module

Exercise: Highlighted Content

Create a new Block display in the left sidebar. The first content should

display its Title and Photo, the rest, display their Titles only.

Page 69: Views Unlimited: Unleashing the Power of Drupal's Views Module

Challenge Exercise:

OpenLayers with

Exposed Filters

Page 70: Views Unlimited: Unleashing the Power of Drupal's Views Module

What's More?

1. Views PDF

2. Entity Views Attachment (EVA)

3. Nodequeue

4. EFQ Views

5. Views Accelerator

6. and so on (explore Views-related modules in Drupal.org)

Page 71: Views Unlimited: Unleashing the Power of Drupal's Views Module

“Views changed my life..”

Page 72: Views Unlimited: Unleashing the Power of Drupal's Views Module

“..and it is about to change yours.”