I see there aren't many filters related to books, yet it would be helpful if we were able to sort by specific books to created views such as "latest entries", "latest pages", "recently edited", etc etc.

Would it be possible to add more book based filters to list the content within books?

Even just a simple filter by book that allows you to select one of the books on your site, would be invaluable in my particular case.

Comments

dawehner’s picture

mh books are just nodes so you can sort filter with the node filters.

recently edited is for example node: updated

highvoltage’s picture

Yes, but books also have children, thus a useful filter might list all the children of a particular book. Displaying particular fields that belong only to particular books would be useful too. There are plenty of possibilities for filters that can be useful.

dawehner’s picture

i'm not sure but did you tryed out the relationships "book parent" and "book" ?

i think you could do all this with them

highvoltage’s picture

I have at one time and I didnt find a way to filter by book. Honestly I'm not sure what uses the available book relationships have at all. Maybe I'm missing something? Would be nice if I could display a list of children of the current book with views(sort of a replacement book navigation using views).

miiimooo’s picture

I agree. It seems there are two ways to only display top level book pages *only* but not a single way of displaying top level book pages AND nodes that aren't part of a book.

Just looking at the query it would be as simple as changing

... AND (book_menu_links.depth = 1)

to

... AND ((book_menu_links.depth = 1) OR ( book_menu_links.depth IS NULL))
miiimooo’s picture

Status: Active » Needs work

I've started writing a views filter to do exactly this and it sort of works - see code below. Now, I'm trying to convert this to proper views syntax but I'm a bit stuck. Should the join look like this:

$join = new views_join('menu_links', 'book', 'mlid', 'mlid');

What other calls should I make to modify the query object to do this?

class child_remover_filter_handler extends views_handler_filter {
  function query() {
//     $table_alias = $this->query->ensure_table('node');
    $table_alias = $this->query->ensure_table('book');
    $table_alias = $this->query->ensure_table('menu_links');
    
    $join = new views_join;
    $join->definition = array(
      'table' => 'menu_links',
      'left_table' => 'book',
      'left_field' => 'mlid',
      'field' => 'mlid');
    $join->extra_type = "AND";
    $join->table = "menu_links";
    $join->left_table = "book";
    $join->left_field = "mlid";
    $join->field = "mlid";
    $join->type = "LEFT";
    $join->adjusted = 1;

    
    $this->query->table_queue['book_menu_links'] = array(
      'table' => 'book_menu_links',
      'num' => 1,
      'alias' => 'book_menu_links',
      'join' => $join,
      'relationship' => 'node');

    $this->query->table['book_menu_links'] = array(
      'count' => 1,
      'alias' => 'book_menu_links',
    );
    $this->query->where[0]['clauses'][] = "book_menu_links.depth = %d OR book_menu_links.depth IS NULL";
    $this->query->where[0]['args'][] = 1;


miiimooo’s picture

Version: 6.x-2.2 » 6.x-2.6
miiimooo’s picture

Status: Needs work » Needs review

I've rolled this into a module. Maybe could be done better and be a patch for views but it's working.

See http://drupal.org/project/views_child_remover

dagmar’s picture

Status: Needs review » Active

If you don't provide a patch, there isn't anything to review.

miiimooo’s picture

Status: Active » Needs review

What about the module?

dagmar’s picture

Status: Needs review » Active

From: http://drupal.org/node/367392

All changes to Drupal, big and small, can be represented by patches. Patches make development easier - instead of saying "I have this replacement file" which may have thousands of lines of code making it difficult to see what the actual differences are, the patch highlights the exact changes that were made for easy review.

We cannot review your module because you post an issue in the view issue queue. If you module provide a solution for this feature request, please change the status to fixed, and category to support request. If not, you have to provide a patch for views.

miiimooo’s picture

ok

webel’s picture

I'm also interested in an 'ancestor' filter against a passed argument, so that I can display selected content from all children (deeply) under a given ancestor.

bomarmonk’s picture

Can either miimo's module or current views functionality allow you to create a view of all nodes-referenced within a certain book? I have book pages with node references, but I would like to show the nodes that the child pages reference on the parent book page (using an embedded view).

bomarmonk’s picture

I've created a separate support request for my question here: http://drupal.org/node/619142

esmerel’s picture

Status: Active » Closed (fixed)

seperate module created, no patch to views, no updates to issue for 6 months.