
As site visitor viewing a documentation collection, I would like to easily switch between different documentation pages in the collection. I would like to do this using a select list at the top of the page, containing all the pages in the collection. I would like the same select list available when viewing the collection itself. This is important since it helps me view the individual pages without having to refer to the collection all the time.
How to Demo:
- Log in to the site.
- Create a documentation collection, linking to at least two documentation pages. (Create documentation pages first, if necessary.)
- At the documentation collection, verify that there is a select list with the included documentation pages.
- When selecting a page in the list, verify that you are presented with the relevant page and that the list is still present.
Required Preparations:
- The site should have the documentation page and collection content types, as provided by the first exercises in this suite.
- The site should be able to display documentation pages in the context of a collection, as described in the previous exercise.
Additional Comments:
- In this exercise it is actually possible to use a standard views block instead of a views content pane – simply because the function for loading the currently viewed node as contextual filter value is fooled by the URL being similar to a collection page. (This won't be the case in the next exercise.)
- The numbering of the pages is a bonus, not asked for in the user story.
- In the jump menu configuration, there is an option select the current contextual filter value. This is an inaccurate description for using the current path as default value in the list – if it matches any of the options. Checking this box will make the select list navigation more natural, since it displays the currently viewed page when possible.
- It may be a good idea to include the collection navigation at the bottom of the documentation pages as well – it seems reasonable that most people are interested in reading the next page when they are done with the current.
Modules:
Additional Resources:
Downloads:
| Attachment | Size |
|---|---|
| 4.87 KB |
Suggested Solution:
- Create a new node view with the name collection navigation. No content type restriction is needed, no sorting, and no displays. (See creating new views in the Views basics chapter.)
- Add a contextual filter content: nid, to filter out the active collection. Set title override to browse %1 and also verify that it is an ID for a collection node. (See configuring contextual filters in the advanced Views configuration chapter.)
- Add a relationship, joining in the documentation pages included in the collection. Make sure to include all deltas. (See adding relationships in the advanced Views configuration chapter.)
- Add a view field content: nid. Exclude the field, and make sure it has no label. (See adding view fields in Views basics chapter.)
- Add another view field content: nid. Use the relationship to the documentation pages, to get the node ID for the page instead of the collection. Enable rewriting, and change the field content to node/[nid]/[nid_1] – the path used for viewing documentation pages in a collection context. Exclude the field. (See rewriting view fields in the advanced Views configuration chapter.)
- Add a view field global: view result counter. Remove any label. (See adding view fields.)
- Edit the title field included by default. Have use the relationship to the documentation pages. Also reorder the fields to have the title last. (See utilizing relationships in configuration in the advanced Views configuration chapter.)
- Change the view style to jump menu. Use the page node ID field as path. (See view formats in the Views basics chapter.)
- Add a content pane display to the view. Change the argument input settings to from context, fetching a content ID from a node available as context. (See input of contextual filter values in views content panes, in chapter 13.)
- Set an administrative title, description and category of the display, so it will be easy to understand its functions when embedding it in a panel. (See using views content panes in chapter 13.)
- In the overview for Page manager, edit the custom page for displaying a documentation page in the context of a collection. Add the new view at the top of the page, using the collection as filter value for the view. (See panel content in chapter 13.)
- At the custom page for node/%node, add a new variant called documentation collections. Use selection rules to only use this variant when viewing collections. (See selection rules and variants in chapter 13.)
- In the collection page, add the collection navigation view pane and the node content of the collection. Make sure that the panel inherits the title from the node content. (See panel content.)
Solution Video: