119
Tips and Tricks for Getting the Most out of Views

Tips and Tricks for Getting the Most out of Views

  • Upload
    acquia

  • View
    943

  • Download
    2

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Tips and Tricks for Getting the Most out of Views

Tips and Tricks for Getting the Most out of Views

Page 2: Tips and Tricks for Getting the Most out of Views

About me

• Drupal consulting, development, and training

• Help organizations build awesome Drupal websites with custom functionality

@suzanne_kennedy

evolvingweb.ca

Page 3: Tips and Tricks for Getting the Most out of Views

Introduction to Views

Page 4: Tips and Tricks for Getting the Most out of Views

What is Views?

Fields

Sorts

Filters

View

Taxonomy

city break

CommentsUsers

D. SchruteGermany

J. HalpertSpain

adventure

city break

sailing

shopping

dwight8 Sept

Wow, can't wait to get visit.

joe8 Sept

Me too!

Content

Content title

Data

Page 5: Tips and Tricks for Getting the Most out of Views

Views BasicsTaxonomy

city break

CommentsUsers

D. SchruteGermany

J. HalpertSpain

adventure

city break

sailing

shopping

dwight8 Sept

Wow, can't wait to get visit.

joe8 Sept

Me too!

Content

Content title

Choose what to list

Choose a format

Choose a display type

Unformatted List Table

Add filters and sorts

Website Header Block Display

Page Display

Page 6: Tips and Tricks for Getting the Most out of Views

Choose What to List

Taxonomy

city break

CommentsUsers

D. SchruteGermany

J. HalpertSpain

adventure

city break

sailing

shopping

dwight8 Sept

Wow, can't wait to get visit.

joe8 Sept

Me too!

Content

Content title

Page 7: Tips and Tricks for Getting the Most out of Views

Add Filters & Sorts

Sort by title

Sort by post date

Filter by content typeArticles Job Postings

Jan 10

March 16

April 6

April 28

Ascending Descending

Jan 10

March 16

April 6

April 28

Ascending

A

Z

Z

A

Descending

Page 8: Tips and Tricks for Getting the Most out of Views

Choose a FormatUnformatted HTML List Ordered List

Table

Ordered List

Calendar Map

Page 9: Tips and Tricks for Getting the Most out of Views

Choose a Display

Website Header Block Display

Page Display

RSS Feed Display

Attachment Display

Page 10: Tips and Tricks for Getting the Most out of Views

Anatomy of a View

ArticlesWelcome to the articles page.

Title

Header

Row

First | Prev | 1 | 2 | 3 | Next | Last Pager

Results

Page 11: Tips and Tricks for Getting the Most out of Views

Anatomy of a View

ArticlesWelcome to the articles page.

Title

Header

Row

First | Prev | 1 | 2 | 3 | Next | Last Pager

Results

Page 12: Tips and Tricks for Getting the Most out of Views

Views: Query builder• <?php

// Connecting, selecting database$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or die('Could not connect: ' . mysql_error());echo 'Connected successfully';mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query$query = 'SELECT * FROM my_table';$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTMLecho "<table>\n";while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n";}echo "</table>\n";

// Free resultsetmysql_free_result($result);

// Closing connectionmysql_close($link);?>

• // Printing results in HTMLecho "<table>\n";while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n";}echo "</table>\n";

Page 13: Tips and Tricks for Getting the Most out of Views

Views Wizard

Choose base tableChange typesTerm filtersSimple sort

Page 14: Tips and Tricks for Getting the Most out of Views

Views Wizard

Page or blockDisplay settingsAdd to menu

Page 15: Tips and Tricks for Getting the Most out of Views

Views Editor

Page 16: Tips and Tricks for Getting the Most out of Views

CHANGING THE MARKUP

Page 17: Tips and Tricks for Getting the Most out of Views

Choose a FormatUnformatted HTML List Ordered List

Table

Ordered List

Calendar Map

Page 18: Tips and Tricks for Getting the Most out of Views

Choose the right format

Page 19: Tips and Tricks for Getting the Most out of Views

Built-in Formats• Table• Unformatted List• HTML List• Jump List• Grid

Page 20: Tips and Tricks for Getting the Most out of Views

Use grids for visual data

Page 21: Tips and Tricks for Getting the Most out of Views
Page 22: Tips and Tricks for Getting the Most out of Views
Page 23: Tips and Tricks for Getting the Most out of Views
Page 24: Tips and Tricks for Getting the Most out of Views

Use tables for tabular data

Page 25: Tips and Tricks for Getting the Most out of Views
Page 26: Tips and Tricks for Getting the Most out of Views
Page 27: Tips and Tricks for Getting the Most out of Views

Display ‘Fields’ for more Control

Page 28: Tips and Tricks for Getting the Most out of Views

Change the row style

Row style setting

Page 29: Tips and Tricks for Getting the Most out of Views

Row Styles

Fields ContentSelect the exact fields that

you want to displaySelect the view mode to use

Select a row style (content or fields)

Page 30: Tips and Tricks for Getting the Most out of Views

Change the markup for fields in configuration

Page 31: Tips and Tricks for Getting the Most out of Views

Altering Field Output

Page 32: Tips and Tricks for Getting the Most out of Views

Exclude fields and rewrite results

Page 33: Tips and Tricks for Getting the Most out of Views

Altering Field Output

Page 34: Tips and Tricks for Getting the Most out of Views

Altering Field Output

Page 35: Tips and Tricks for Getting the Most out of Views

Use Field Formatters

Page 36: Tips and Tricks for Getting the Most out of Views

http://blog.brightcove.com

Page 38: Tips and Tricks for Getting the Most out of Views
Page 39: Tips and Tricks for Getting the Most out of Views
Page 40: Tips and Tricks for Getting the Most out of Views

Use custom view modes

Page 41: Tips and Tricks for Getting the Most out of Views

Define custom View modes with Display Suite

Page 42: Tips and Tricks for Getting the Most out of Views

Add multiple displays to the same View

Page 43: Tips and Tricks for Getting the Most out of Views

Multiple Displays

Page 44: Tips and Tricks for Getting the Most out of Views

Add displaysAdd displays

Page 45: Tips and Tricks for Getting the Most out of Views

Override Settings

Select to change settings for the current display or all displays

Page 46: Tips and Tricks for Getting the Most out of Views

Use attachments to make a ‘featured item’

Page 47: Tips and Tricks for Getting the Most out of Views
Page 48: Tips and Tricks for Getting the Most out of Views
Page 49: Tips and Tricks for Getting the Most out of Views

Group results for easy scanning

Page 50: Tips and Tricks for Getting the Most out of Views
Page 51: Tips and Tricks for Getting the Most out of Views
Page 52: Tips and Tricks for Getting the Most out of Views

Select grouping field

Page 53: Tips and Tricks for Getting the Most out of Views

Use Views to Create RSS Feeds

Page 54: Tips and Tricks for Getting the Most out of Views

Attach a Feed Display

Page 55: Tips and Tricks for Getting the Most out of Views

Link a block to a page display

Page 56: Tips and Tricks for Getting the Most out of Views
Page 57: Tips and Tricks for Getting the Most out of Views

Link a block to a page

Link display setting

Page 58: Tips and Tricks for Getting the Most out of Views

FILTERING AND SORTING

Page 59: Tips and Tricks for Getting the Most out of Views

Add Filters & Sorts

Sort by title

Sort by post date

Filter by content typeArticles Job Postings

Jan 10

March 16

April 6

April 28

Ascending Descending

Jan 10

March 16

April 6

April 28

Ascending

A

Z

Z

A

Descending

Page 60: Tips and Tricks for Getting the Most out of Views

Adding FiltersAdd something to filter by

Configure it

Page 61: Tips and Tricks for Getting the Most out of Views

Filter by whether a field exists

Page 62: Tips and Tricks for Getting the Most out of Views
Page 63: Tips and Tricks for Getting the Most out of Views

Operators for Filters

Filter to show onlyusers who have a picture.

Page 64: Tips and Tricks for Getting the Most out of Views

Use exposed filters to let users filter content

Page 65: Tips and Tricks for Getting the Most out of Views
Page 66: Tips and Tricks for Getting the Most out of Views
Page 67: Tips and Tricks for Getting the Most out of Views

Exposing a filter

Page 68: Tips and Tricks for Getting the Most out of Views

Modules for Filtering• Better Exposed Filters• Provides more options for exposed filters

• Views Dependent Filters• Exposed filters that show up when a

particular option is selected

Page 69: Tips and Tricks for Getting the Most out of Views

Use exposed filters for search

Page 70: Tips and Tricks for Getting the Most out of Views

Exposing Search• Provide a ‘keywords’ exposed filter

Page 71: Tips and Tricks for Getting the Most out of Views

Exposing Search

Page 72: Tips and Tricks for Getting the Most out of Views

Display content in a table and expose sorts

Page 73: Tips and Tricks for Getting the Most out of Views

Exposed Sorts• Use a table view and expose sorts to users

Page 74: Tips and Tricks for Getting the Most out of Views

Exposed Sorts

Page 75: Tips and Tricks for Getting the Most out of Views

Use the Date Views module

Page 76: Tips and Tricks for Getting the Most out of Views

Upcoming Events View

Page 77: Tips and Tricks for Getting the Most out of Views

Filtering by Date

Filter to only show results with a start date in the future

Page 78: Tips and Tricks for Getting the Most out of Views

USING CONTEXTUAL FILTERS AND RELATIONSHIPS

Page 79: Tips and Tricks for Getting the Most out of Views

Contextual Filters: Page

Website Header

Page Display

Alias: category/tags/drupal

Drupal System Path: taxonomy/term/1Content About ‘Drupal’Views Configuration: taxonomy/term/%

URL: evolvingweb.ca/category/tags/drupal

Page 80: Tips and Tricks for Getting the Most out of Views

Contextual Filters: Page

Add a contextual filter

Configure it

Page 81: Tips and Tricks for Getting the Most out of Views

Contextual Filters: Block

Website HeaderBlock Display

Alias: content/blog-post-title

Drupal System Path: node/1

URL: evolvingweb.ca/content/blog-post-title

Node 1 Content

Tags for Node 1

Page 82: Tips and Tricks for Getting the Most out of Views

Contextual Filters: Block

Add a contextual filter

Configure it

Page 83: Tips and Tricks for Getting the Most out of Views

Use contextual filters to show related content

Page 84: Tips and Tricks for Getting the Most out of Views

Field in Separate Block

View showing the technology field. Uses contextual filter to show only data for current node.

Page 85: Tips and Tricks for Getting the Most out of Views

Related Media Block

View showing the ‘Related Videos’ field. Uses contextual filter to show only data for current node.

Page 86: Tips and Tricks for Getting the Most out of Views

Use contextual filters to exclude results

Page 87: Tips and Tricks for Getting the Most out of Views

Exclude current node

Page 88: Tips and Tricks for Getting the Most out of Views

Exclude arguments

Page 89: Tips and Tricks for Getting the Most out of Views

EXTENDING VIEWS

Page 90: Tips and Tricks for Getting the Most out of Views

Setup Views for administrators

Page 91: Tips and Tricks for Getting the Most out of Views

Administrative Views

Page 92: Tips and Tricks for Getting the Most out of Views

Draggable Views

Page 93: Tips and Tricks for Getting the Most out of Views

Draggable Views

Page 94: Tips and Tricks for Getting the Most out of Views

Views Bulk Operations

Page 95: Tips and Tricks for Getting the Most out of Views

Use Views & Apache Solr

Page 96: Tips and Tricks for Getting the Most out of Views

Apache Solr• Apache Solr Views Integration module

Page 97: Tips and Tricks for Getting the Most out of Views

Display more data with Views

Page 98: Tips and Tricks for Getting the Most out of Views

What else can you show with Views?

• Aggregator items• Solr search results• Content Revisions• Products• Media• Webform Submissions• Files

Page 100: Tips and Tricks for Getting the Most out of Views

Your Custom Data

Page 101: Tips and Tricks for Getting the Most out of Views

Use Views Slideshow for dynamic rotators

Page 102: Tips and Tricks for Getting the Most out of Views

Views Slideshow

Page 103: Tips and Tricks for Getting the Most out of Views
Page 104: Tips and Tricks for Getting the Most out of Views

Views Slideshow Config

Page 105: Tips and Tricks for Getting the Most out of Views

Use the Calendar Module

Page 106: Tips and Tricks for Getting the Most out of Views

Calendar

https://buyandsell.gc.ca/event-calendar

Page 107: Tips and Tricks for Getting the Most out of Views

https://ed.stanford.edu/events

Page 108: Tips and Tricks for Getting the Most out of Views

Building a Calendar• Calendar provides a views template

Page 109: Tips and Tricks for Getting the Most out of Views

Maps!

Page 110: Tips and Tricks for Getting the Most out of Views

Open Layers Views

http://www.gfptt.org/

Page 111: Tips and Tricks for Getting the Most out of Views

WORKING WITH VIEWS

Page 112: Tips and Tricks for Getting the Most out of Views

Preview Output

Page 113: Tips and Tricks for Getting the Most out of Views

Previewing Output

Page 114: Tips and Tricks for Getting the Most out of Views

Export Your Views

Page 115: Tips and Tricks for Getting the Most out of Views

Views in CodeExport Views

Add Views to Your Features

Page 116: Tips and Tricks for Getting the Most out of Views

Use the ‘Theme Information’ link

Page 117: Tips and Tricks for Getting the Most out of Views

Theme Information

Page 118: Tips and Tricks for Getting the Most out of Views

Theme Information