Creating a view block that contains all children of a certain book page is not that difficult. Suppose we have the following book hierarchy:
- Book title
- Chapter 1
- Section 1.1
- Section 1.2
- Chapter 2
- Section 2.1
- Section 2.2
We will show how to create a block that will show the relevant section pages on the "Chapter 1" and "Chapter 2" pages.
- Browse to /admin/structure/views and click on "Add new view".
- Enter a view name, uncheck the "Create a page" checkbox and check the "Create a block" checkbox. Then click on "Continue & edit".
- On the right-hand side, click on "Advanced" so that the advanced menu appears.
- Click on "add" next to "Relationships" to add a relationship.
- Select "Book: Parent" (the parent book node) and click on "Apply (all displays)".
- In the "Configure Relationship: Book: Parent" screen, check the "Require this relationship" checkbox and click on "Apply (all displays)".
- Click on "add" next to "Contextual filters" to add a contextual filter.
- Select "Content: Nid" (The node ID) and click on "Apply (all displays)".
- In the "Configure contextual filter: Content: Nid" screen,
- change the relationship to "Book Parent"
- in the "when the filter value is not available" section, select "Provide default value" and in the "Type" dropdown menu, select "Content ID from URL"
- click on "Apply (all displays)"
- Remember to click the "Save" button on the top-right to save your view.
You have now created a block that will show the children of a certain book page. To add the block to a certain page, browse to "/admin/structure/block" and configure the block.