Request for Book Title Module

Created on 2 December 2022, almost 2 years ago
Updated 19 December 2023, 11 months ago

Hi,
This is probably a little out of scope, but I figured I'd ask and the worst that could happen is that you'd say no or maybe you could point me in a direction.

I have a site with a lot of books and one thing I'd like to do is to have the Book Title at the top of the page without hand-coding a block for every book on my site. I'd like to just have one module that displays the title just like this one does with the menu (automatically changing depending on the book you're in).

Currently what I've done is to take this module and used CSS to hide all the nav links since it displays the book title above the menu.
This works well, but I'd like to reduce the HTML bloat and I've spent all day trying to figure out how to clone the module so I can only have the title show up, but it never gives me a block I can choose from in the Place Block popup on my site. (I've tried changing every function name, file name, etc in the module to no avail - I'm not much of a coder and can't really understand what needs to be done)

Is it possible for you to add a block to this module that just outputs the title of the book and [optionally?] link's to the book's home top parent page?

Thank you for your amazing work on this module, it is truly the backbone of my site's menus and I was thrilled when I found it.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rex.barkdoll

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺ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 1

    Set 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.

Production build 0.71.5 2024