Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 1.91 KB

views.md

File metadata and controls

43 lines (38 loc) · 1.91 KB

Views

Building Views

The following are guidelines for building new views.

  • Caching
    • For all public facing views, always use some form of caching. A non time-based cache is preferable because it often permits the longest cache lifetimes, and invalidates caches only when necessary. Possible options are:
  • Pagination
    • Always specify either a fixed number of results or a pager. Never display all results.
    • Whenever possible, use Views lite pager rather than a full pager.
  • Advanced
    • Always add a semantically descriptive machine name to views displays. E.g ., use press_releases_all rather than page_1. This makes all PHP, CSS, and JS related to the view display more readable.
  • Relationships
    • Whenever possible, use "require this relationship" for all views relationships. This causes views to perform an inner join rather than a left join, and is almost always faster.
    • Never use the Taxonomy Terms on Node relationship or filter. Instead, use a relationship or filter for the specific taxonomy reference field. This has a tremendous performance impact.
  • Filters
    • For all exposed filters, manually set the fitler identifier to something end-user friendly. This should not contain drupalisms. E.g., use type rather than field_type.
  • No Results Behavior
    • Always add "No Results behavior" of some type. This is typically text informing that user that no results were found.

@todos:

  • When to ditch Views in favor of EFQ or straight queries. There's a reason Advanced Forum is slow on big sites.
  • Proper views naming and tagging