Guide to Profitable Sales

Logo

Views

One of the most powerful things Drupal, and probably why you selected a content management system (CMS) approach to your site, is the availability of VIEWS into your information. Think about creating content. You selected or created a content type, you managed the fields within it, and you populated the content (e.g. think multiple articles). You logically aren’t going to create a menu link to each individual article once the count is over say half a dozen. You aren’t going to string a stacked sequence of every article you create on top of each other on a single page or node. Rather, you probably want to give your user a summary of article titles, maybe a short trimmed amount of its content, and maybe the date on a list, some cards, some blocks around a front or section page, etc. Then you want to create those with a View.

Views & Views UI modules

The Views and Views UI modules are part of Drupal Core. You may want to confirm they are enabled under Admin/extend to see that they are check-marked. With that you are ready to use this basic views capability. WebWash provides a nice video training overview to get you started. And, you can even take their course on Views for more depth.

Combining Filters

There is so much power in Views it is hard to communicate it all. One often overlooked is an option under the ‘Filter Criteria’ for a Global filters: Combine Fields. Without sending one down a whole additional computer language, it might help to understand that Views is basically making an SQL query into the database to pull the specific information filtered to exactly what you are seeking to display. You can even configure Drupal to show the actual SQL Query syntax of your View. An example of how you might set up a Search View across multiple fields may help; and you even get to see the SQL Query is set up as ‘AND’ combinations in how this one was set up.

Views of Forms

The crazy thing about Drupal is that it is built upon itself. What this means is that when a User signs up to your website, the little form they fill out is actually built by a View. Since that little form is a User Entity type you can add more to the sign up form that comes out of the box. It would be common to add asking for some information about your airplane model on an aviation site, or what ratings you have, or how many hours. But simply adding fields to an entity is not where it stops. Heck, you can add a whole new tab on the form. An example might be a tab for the articles that a user has contributed to the website. But basically, you can add a custom tab for a variety of purposes. Infact, if you can define a query of something that is part of your website, you can use Views to present the results in a ton of different ways.

No result

If the above example, it would be logical that a new user would not have any articles they contributed yet. In fact, in any number of the Views queries that take place, there is a reasonable likelihood that in some situations nothing will meet the criteria. So the results are null, empty, nothing, and yet you have some sort of ‘home’ you have set aside for those result to appear. You don’t want an empty home to show up. What do you do with a no result return in Views?

View a Field as a Block

Views in core can do a ton of things. That includes taking a Field from your content entity and pulling it out of the body of the node it is part of and displaying it as a Block that you can place in a Region. As that video shows, Views can handle this task and leverage all sorts of configuration settings for a View in doing so. But sometimes you want just the KISS approach to allow you to set a field as a block right from your traditional ‘Manage Display’ settings tab for the content type.

Views modules

Fieldblock module

There is a popular contributed module that does allow you to set a field as a block from the ‘Manage Display’ settings tab.

composer require drupal/fieldblock
drush en fieldblock

Views Block Expose Filter Blocks module

One of the things you see toward the end of that video is how you can create a ‘block’ view from a copy of the ‘page’ view and then set the block view as independent so you can edit it down to something more unique and narrow in scope. You also saw that you can set up filters that a user can control rather than just how you might have done a filter down to the subset of what underlying content is viewed. By putting that filter in the users hands they can focus where they want. But you might want to use that filter on a block and place it physically in a separate block visually; this module gives you that power.

composer require drupal/views_block_filter_block
drush en views_block_filter_block

Lazy Views module

Lazy load is a performance enhancement and the Lazy View module brings that benefit as well as simply button or page load triggers to pull the view.

Views Combine module

Once you get going with views you will likely create a number of them. And in a world where your site layout has regions with blocks deployed in various areas for different purposes you may find that the intersection between two view you have created query retrieval for make more sense to present in an integrated way. You just ran into the purpose of the Views Combine module.


Both the Lazy Views and Views Combine modules were developed by the same group and they provide a nice detailed set of instructions.


Views Field View module

I think of the Views Field View module as basically ‘nested views’. A demonstration of how to combine it with taxonomy to present grouped movie reviews by genre can show you a good example use case.

Views Flipped Table module

Views offers options on the way it displays the query results. Things like an unformatted list, grid, table, etc. This module simply flips the rows and columns from a standard table to display the other way around in case you happen to have more columns than rows in what you are pulling.

composer require drupal/views_flipped_table
drush en views_flipped_table

Views Slideshow module

The Views Slideshow module is more than an image slideshow. You can slideshow any item; like the last X articles, the latest forum posts, the newest products, etc. Go to the Drupal.org site for the installation of this module as it requires some JavaScrip libraries be installed above and beyond your traditional composer install…

Views Infinite Scroll module

A typical deployment of views has a pager that you can configure for how many pages, style of paging, etc. The Views Infinite Scroll module adds one more option to that which adds content as you scroll down rather than clicking to a new page. See how to install it and even customize the scroll behavior.

composer require drupal/views_infinite_scroll
drush en views_infinite_scroll

Views Layout module

The Views Layout moduleis sort of like a stripped down Layout Builder that lets you select different column counts in stacked rows to display Views output in a little more creative way than just grids or tables. It can be used with the Layout Plugin Views module if you want to go incrementally a little more nuts on field level presentation in the rows you are stacking.

composer require drupal/views_layout
drush en views_layout

Core Views Facets module

If you want to use Facets within Views, also install and enable this add-on.

composer require drupal/core_views_facets
drush en core_views_facets

Views Bulk Operations module

The Views Bulk Operations module is a workhorse. You probably want to make sure you have a good backup copy to restore your website in case you do something unintentional with it. Also, you might first try something simple, and lower risk like moving a bunch of stuff from an unpublished to a published state; in a sense what the Moderated Content Bulk Publishing module is doing in Content Moderation. However, you can do a whole bunch more in BULK, including deleting a bunch of stuff. That might be a good thing if it is time to clean up a dated site for old content with a date filter on old articles. However, it probably will pay dividends to watch this basic video before you jump into using this module.




Learn More - Drupal Modules List