Project: Views
Version: 5.x-1.6
Component: book data
Category: support request

I'm attempting to create a view that displays recent book pages in a block, I can get the block to display the parent pages, but none of their children.

Example:

Book
- Parent1
--Child Page
- Parent2
--Child Page

But my block will only display:
- Parent1
- Parent2

I've posted this in the support request section of the views module page, but it suggests posting in the forum due to lack of responses.. so here it is, thanks if you can help.

Comments

KrisBulman’s picture

can it be done, or is it not possible with the current version of views?

seutje’s picture

filter -> Node: Type - Is One Of - Book page
filter -> book: parent id - is none of - 0 (zero)

block view type: List view

Fields -> book: parent title
Fields -> Node: Title

Sort Criteria -> Book: Parent title

this should make ur block show up like this:

- Book title
page title
- Book title
page2 title
- Book2 title
page title
- Book2 title
page2 title
...

this isn't exactly what u are looking for, neither is it what I was looking for

I'm gonna check out views fusion and see if it's a better way

might just use node reference or groups instead

oh and this is with views2, but I don't think it makes a difference

mariagwyn’s picture

I am trying this on d6.x and views2, but I don't see the following as options:

filter -> book: parent id - is none of - 0 (zero)
or
Fields -> book: parent title

The only book filter and field options I have are weight and depth.

Am I missing something obvious?

m

A-Aas’s picture

i m also having the same problem couldnt access the book title option how can i do it ... is there a way out to display book name while creating views ....in drupal 6 .....

TimDavies’s picture

I was seeing a similar problem - but as far as I can tell all these options have now moved into 'Relationships' rather than being Filters.

kayceedub’s picture

It's been a while since the last comment but thought I would put down what I did, in case it helps others, as I was really struggling with this.

To get the children items to display, what i did was:

Relationships -> Book: Parent

Then under Filter, added one for Node: NID, hit add, then on the next screen, select Book Parent from the relationship dropdown. From there, I was able to enter the node id for the book I want to use. It ends up looking something like "(Book parent) Node: Nid = 3501".

In this case, I'm saying, find results where the book parent's node id is 3501.

And if that doesn't do it for you, this article shows you how to do it outside of views: http://drupal.org/node/209336

Hope this helps somebody.

Tagert’s picture

Well, after a bit of fiddling I got it to work well enough.

Basically follow the same steps:

Relationships -> Book: Parent

Instead of putting it under filter, though, put the '(Book Parent) Node: Nid' as an argument. Then you can pass the argument through to the view.

Anonymous’s picture

"Instead of putting it under filter, though, put the '(Book Parent) Node: Nid' as an argument. Then you can pass the argument through to the view."

Please explain this part. I am selecting Book: Parent as the relationship in the argument, and cannot get it to work with the view. These thing should be specified in the posts we all make.

Tagert’s picture

It should work. I'll go through the steps I have:

First and most importantly you need to add 'Book: Parent' as a relationship. In my setup it I have the 'Required Relationship' option enabled.

After that is added, then choose the argument 'Node: Nid' and click 'Add'. Before confirming this argument, change the 'use relationship' to 'Book Parent'.

Now setup how you want your view to look. (In my setup I have Node: Title, Node: Edit Link, Node: Teaser, Node: Delete link)

You should then be able to pass the nid of the parent page to the view and the view will display the children of that nid. (Note: I don't have a Page for the view setup, I simply call the view from within the page using module Insert view)

There is no other configuration on my end.

Dret’s picture

I'm trying to set a Views as replacement of Book standard navigation system.

In other words: I need a Views that display on Parent Page all the list of child page (for that book) and on the "Child" page all the others "sisters" page (for that book).

The Views must be a block-views and the variables (nid or bib) have to be passed in dynamic way!

... the result should be similar to this direct Db Query:

$sql = 'SELECT * FROM drupal_node WHERE nid IN (SELECT nid FROM drupal_book WHERE bid =20) and nid <> 20'
        . ' UNION'
        . ' select * from drupal_node where nid in ('
        . ' select nid from drupal_book where bid in ('
        . ' SELECT drupal_book.bid '
        . ' FROM drupal_node inner join drupal_book'
        . ' on drupal_book.nid=drupal_node.nid'
        . ' where drupal_node.nid <> drupal_book.bid '
        . ' and drupal_node.nid = 20) and bid<>nid and nid<>20)'
        . ' ';

WARNING= the value 20 is the one that have to be replaced dinamically.

SomeOne can help me?

Thanks a lot!
Bye!