Active
Project:
Debut
Version:
7.x-1.x-dev
Component:
Debut specification
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2010 at 21:35 UTC
Updated:
25 Nov 2010 at 00:26 UTC
How should views be named? Tagged? What are appropriate display names? public and admin titles? Etc. We may as well nail this down in as much detail as possible. The more uniform and predictable, the better.
Comments
Comment #1
rhache commentedGeneral Guidelines for Creating Views
These recommendations came from preparation for a talk at the 2010 Pacific Northwest Drupal Summit entitled "Build Views that will please your OCD co-workers". Thanks for the feedback. And yes, the OCD part applies to me.
Creating the View
Creating displays
Give a distinctive name for each display. For example, the following display names for each display might be necessary for an event section:
Some have made the argument that each display name should also include the display type. For example, "Landing" in the example above would be "Landing Page", and "Upcoming Sidebar" would be "Upcoming Sidebar Block". Personally I find this somewhat redundant. Properly naming a display by it's function should make this obvious.
Override Only Settings
Some settings in a display's basic settings, due to their nature, are better being always overridden on each display. They are:
Style
display: inline-blockCSS property (for elements with varying heights).Row style
If you are using Semantic Fields row style the context is what will determine the appropriate choice for surrounding HTML element. Generally, it is best to utilize the heading elements (h1 to h6) as much as possible to maximize SEO performance. For certain fields, like single image fields, it might be appropriate to not surround the field with any HTML element.
Working with Semantic Views
When using Semantic Views as the display style, a user can specify the wrapper element of each views row (or omit it completely). The most common choices will either be a
divor ali. Regardless of your choice, we recommend the following class names:views-row views-row-# name-of-content-type. The reason for specifying a views-row class is for consistency across displays. Some types of displays don't allow Semantic Views row style, so adding aviews-rowclass give you the ability to globally style displays, regardless if were using Semantic Views or not on some of them.As for the Semantic Fields row style, the right element and class depend greatly on what you are displaying. For example, an image may not require any wrapper element. Generally, it is important to maximize the use of heading elements (h1-h6) for increased SEO perfomance. If your theme uses the
h1element for page titles, andh2for block titles, then you typically would want the first fields in a row to beh2for page displays andh3for block displays, and so on for following fields.CSS Setting
A set of three CSS classes is recommended for each display. For example the events landing page mentioned above should have the following CSS setting: "events-displays events-pages events-landing". The benefit of each CSS class are:
There is one exception to this recommendation for blocks and content panes, depending on your theme's requirements. This is because they are already surrounded by a wrapper with either a unique ID (in the case of blocks with good starter themes) or classes (as is the case for panels where you can specify either an ID or classes)
Block and content panes
Rewriting fields
One of the most powerful features of Views is the ability to rewrite the output of the fields. Together with the ability to exclude fields from display, we can combine several fields together.
For example, we may want to combine a user name and post date fields together so they are presented on one line: ie. Posted by Jake on November 3, 2010
Here are some recommendations when rewriting fields:
[name] [created]. At this point, the output would be Jake November 3, 2010.Posted by [name].on [created].Be careful of how you rewrite fields. For username and post date in the example above, we can be fairly confident that those will never by empty, but that is not the case with all fields. For example, imagine that the post date was some optional field. The reason I chose to add the word "on" in the post date fields is that if the date field was left empty, we could end up with this: Posted by Jake on: an incomplete sentence that looks silly.
Caching
Just prior or at launch, make sure to enable caching to improve performance on your site. It is highly recommended that you use the Cache Actions Module in conjunction with caching your views. Cache Actions allows you to clear a views cache with the Rules module. This means that whenever a user creates a event node, we could clear the events view cache to update the displays immediately. This is particularly useful when a third party will be creating the content, especially if they don't understand caching.
Comment #2
GregoryHeller commentedThis looks good. A few questions for @rhache: should the view displays be all lower case or have init caps? It is worth noting that block displays should have the administrative description field filled out with a meaningful & concise description.
Missing from the above is your recommendation that when using the re-write field option with a field style display, you recommended using the global: custom text field and suppressing the display of the fields to be rewritten.
I'd also like to see something about the recommended naming convention for feed displays, specifically the url path.
Comment #3
rhache commentedHi Gregory,
In my opinion, the view display names should have an initial capital, be somewhat human readable but as concise as possible.
I'll add the bit about rewriting fields soon, I had forgotten about that.
As for feed displays, I usually simply add /feed at the end of the url of the page display it's related to -- ie if I have page display with a "blog" path, the main blog feed would be "blog/feed" (I know feeds are not always tied to a page, but usually yes in my experience). However, I'm not a big RSS expert and would appreciate other opinions. I'd also like to know if for feeds if it's recommended to have a particular "items to display" value.
Thanks,
Rene
Comment #4
rhache commentedAdded some bits about Semantic Views and recommendations for rewriting fields.
Rene
Comment #5
nedjoThanks Rene. This is great. I'll need to merge in the bits we already have in the debut features spec. The only piece I'm unsure about is adding a dependency on Semantic Views. Once adopted, we'll need to update all existing views. I might not get to this soon but like the direction.