Table with a collection's documentation pages

As site visitor viewing a documentation collection, I want to see a table summarizing the documentation pages within the collection. The table should have documentation page title, first 200 characters or so, and comment count. This is important since it makes it easier for me to find documentation I am interested in.

How to Demo: 
  1. Log in to the site and create a documentation collection, if necessary.
  2. View a documentation collection. Verify that its related documentation pages are listed in a table at the bottom of the page, with name, the first 200 characters (or so) of the body, and comment count. Also verify that the title links to the full documentation page.
Required Preparations: 
  • The site should have the documentation page and collection content types, as provided by the first exercise in this suite.
Additional Comments: 
  • It is logically correct, but not entirely intuitive that you restrict the objects listed in the view to documentation collections – while what's being displayed is documentation pages. It might help thinking of relationships as providing new fields on the object you are listing: the collection gets new fields like collection:page:title and collection:page:body.
  • Make sure that you add the fields used on the documentation page rather than the documentation collection – and of course to select the right relationship in the field configuration.
  • The default order of the relationships will be their deltas – their sorting order in the documentation collection. You could, however, sort by documentation page title or any other available data if you want to override this.
  • The view's limit on item to display relates to the base objects loaded by the view – meaning that even if you restrict the number of collections to one, all related pages will show. This is in parallel to how Views would handle a multiple-value field – if the view is configured to display each value as a separate row, each row won't count as a new result in the database query created by Views.
  • At the block administration page, it makes sense to set block visibility to only show at documentation collection pages. The view wouldn't display anything at other pages, but setting the block visibility would prevent Views from ever being called – saving some performance for your site.
Modules: 
Downloads: 
AttachmentSize
3.13 KB
Suggested Solution: 
  1. Add a new view with the name documentation pages in a collection, and have it list content of type documentation collection. Create a block displaying a table, and set the title to documentation pages in this collection. (See creating new views in the previous chapter.)
  2. Add a contextual filter content: nid. If no filter value is present, build a default value with content ID from URL. Use validation to assure that only collection node IDs are accepted. (See managing missing filter values and configuring contextual filters in chapter 10.)
  3. Add a relationship, using the node reference field on the documentation collections. Make sure to use all delta, to collect all related documentation pages. (See adding relationships in chapter 10.)
  4. Add the documentation page fields you want to display, using the relationship to the documentation page. Make sure to also update the title field, provided by default. (See utilizing relationships in configuration in chapter 10.)
  5. For the documentation page body, either use the trimmed formatter or use the Trim this field to a maximum length in the rewrite results settings, to limit the body to 200 characters. (See rewriting view fields in chapter 10.)
  6. Give the view block an administrative title. (See display specific settings in the previous chapter.)
  7. In the block administration page, place the new view block at the bottom of the content region. (See regions and blocks in the blocks chapter.)
  8. Change the field display settings for documentation collections, to hide the default output of the documentation page references. (See field display settings in the view modes and field display chapter.)
Solution Video: