- π©πͺGermany tfranz
You can do that with views:
Create a view: for fields, showing as block, showing book pages
Add a Relationship to "The book the node is in."
Add a title-field with relationship to the "The book the node is in." (<- Thats the trick!)... and you have to add a context in order to show only the corresponding book title, if you have more than one book.
(Attached is my config-file for the view as a starting point β including the context-settings.)
- πΊπΈUnited States rex.barkdoll
I want to update this view setup for Drupal 8/9/10+
Create a view with a unformatted list of fields of any content (or book content if only book entities can be in books).
Limit the view to 1 result.In your View, add a Relationship: Top level book. This shows as Book once the relationship has been added to the view. I don't think you have to Require this Relationship.
Add a contextual filter: ID - Content. (the ID under the category Content).
- Under relationship, choose Book.
- When the filter value is NOT available: Provide default value
- Type: Top Level Book from current node.Make sure Pager is set to: Display a specified number of items: 1
Fields: Update your title field.
- set Relationship to: Book
- Check: Link to the content (if you want users to be able to click the link to return them to the Book "home" page)
- Style Settings:
- Check customize field HTML and set it to H1 (if this is how your HTML is structured for accessibility)
- uncheck Add Default Classes
- OPTIONALLY: Set the Label and Wrapper elements to none to reduce code.Filter Criteria
- Add a Depth filter
- Require the Book relationship
- Set the value equal to 1Set your block name
Save your view
Add it to your Block position
Style Appropriately. - πΊπΈUnited States rex.barkdoll
Adding my View's YML file if you'd rather just import it.