I'm currently trying to create a block which will contain page titles (the child pages of a book) linking to the full book node in views. My only problem is that I don't know how to specify which book I want since I have a few books and will be created a separate block for each.

So does anyone know if its possible to specify which book I would like the view to use and if so how?

Thanks.

Comments

shanehussainnaqvi’s picture

i am stuck with the same problem. i tried doing it through the block all tpl and also by creating a view but its not working. its displaying all books's children and not just the current books.
My objective is to create a "related pages" kind of block so that only the siblings or children of the current page may be displayed and not all pages.

anyone?

ljfc’s picture

I'm having exactly the trouble described by the others here. The view is to be used as input to a views carousel. I suppose I could apply a taxonomy term to specifically identify the relevant pages, but that doesn't seem quite right somehow.

tuphill’s picture

i found this looking for something else so I thought I'd give a quick answer. We do this a few places.

In the view
- add a relationship that is Book: Top level Book
- add an argument that is Node:Nid, provide the default argument as the top page of the book.
- make the argument require the relationship.

That will only pull nodes that are children of the top level book.

Hope that helps.

Now back to finding the solution to my own problem...

c0ldfury’s picture

That does not provide the children of the current node.

zviryatko’s picture

thanx you!

capysara’s picture

Thank you! This worked great!

1mundus’s picture

Add relationship:

Book Parent (tick "Require this relationship")

Add argument:

Content: Nid
- Provide default value - content ID from URL
- Use relationship Book Parent

That's it. Filter the results as you wish.

timmerk’s picture

This shows the first level of children, but is there a way to show the children of the children, etc? Thanks!

knard’s picture

For me I was looking to display the Book Parent as well as every child element no matter how nested the child pages. But also output every book individually so that I can later make a pdf of the view and archive it monthly. 

First the Relationship:  Choose Book: Top Level

You don't have to require the relationship

Next Contextual filter: Content: Nid

You can use the require the relationship here but there is only one so you can skip that.

Format Show: Content | Full content . No relationship needed but the view mode is Full content

Filter criteria because I want just one book at a time and its child pages you need to filter by Content: NID. Choose Top level for the relationship and your Operator should be Is equal to. The value should be the parent node id. 

joarferme’s picture

I created two views, one view to display the list of books and a second view to display book's child pages.

First View: List all books
FORMAT: Table
FIELDS
Content: ID [hidden]
Content: Title
Content: Link to Content
            Rewrite Results: <a href="{{ your_custom_path }}/{{ nid }}">View</a>
FILTER CRITERIA
Content: Content Type = Your book content type
Book: Depth 1
RELATIONSHIPS
None
PATH
/your_custom_path

Second View: Book's child
FORMAT
Table
FIELD
Book: Depth
Content: Title
            - Rewrite Results
              {% if depth==1 %}
              <strong>{{ title }}</strong>
              {% elseif depth==2 %}
              {{ title }}
              {% elseif depth==3 %}
              --{{ title }}
              {% elseif depth==4 %}
              ----{{ title }}
              {% endif %}
FILTER CRITERIA
Content: Content Type = Your book content type
(Don't include Depth on this view)
RELATIONSHIPS
Top Level Book
CONTEXTUAL FILTERS
   Content ID
               Relationship Book
               Provide default value
                   Content ID from URL
PATH
/your_custom_path/%

It works great for me

frustratedDEV’s picture

I almost followed what you did here, but the difference is in format, instead of the table, I used an unformatted list for both views and content fields. Unfortunately, some child pages are not visible in a particular book. I have a one book page where the child pages are complete, but most of the book's child pages don't display.

to display the list of book:

Format: Unformatted list
Show: Fields
Filter Criteria:
Content Published (=Yes)
Content: Content type (= Services)
Book: Depth (= 1)
Sort Criteria: Content: Title (asc)

to display the child pages:

Format: Unformatted list
Show: Fields
Filter Criteria: Content Published (=Yes)
Sort Criteria: Content: Title (asc)
Contextual Filters: (Book Parent) Content: ID
Relationships: Book Parent

After saving it, I added this to the block layout.

Thank you and I hope you can help me.

AndiePie’s picture

I have created a bunch of different books. I have created a bunch of different navigation blocks in VIEWS. Each book has a navigation block displaying all the pages OF THE BOOK. 

I would like to place a BOOK ONE navigation block only on pages of Book One. Right now, I need to go to the block display and do it manually like this:

display block on the following nodes:
node/1
node/2
node/3
node/4

etc... I need to manually put in all the nodes that are in book 1, so the block will show up on those nodes... 

This is a HUGE PAIN THE ASS, because new pages don't update automatically, i need to manually add the new nodes in so the NAV BLOCK will appear... 

Is there a way to display block on ALL NODES OF BOOK 1? This way, when I create new pages in Book 1 or Child pages within book 1, they still all belong to book 1 and so the nav block will automatically appear on those pages. 

Thanks...