Skip to content

Drupal Views

What's views?

  • The Views module, in core since Drupal 8, allows you to query your site’s database,
  • and present it to the user as lists, posts, galleries, tables, maps, graphs, menu items, blocks, reports, forum posts, webfeeds, JSON text files etc.
  • In other words, it provides a graphical interface to a SQL query builder that can access virtually any information in your database and display it in any format.
  • Basically views are lists. Lists of nodes or fields (contenttype fields)
  • They come in page or block format,
  • and the module can be extended in (many, many) various ways. For instance with the module I added to your default groupsite.

Some example views

Creating a view

As with content types a number of views come out-of-the-box, enabled by default. But most of the time you will make your own. This is actually the second phase in you web-building workflow, after building and populating the content types for your site.

  • views live under 'admin/structure/views'
  • take a look at some of the default (enabled) views
    • content
    • frontpage
    • taxonomy term
  • you start making a custom view with the 'add-view' form

Adding css to a view

  • Adding (w3.)css to a view is almost identical to the procedure we used for content types. The functionality of adding w3.css classes to a view is provided by a neat little module, Field Formatter Class.
  • adding w3.css classes to a field's style settings
    • uncheck 'add default styles'
    • customize field html
    • create css class