book.views.inc

  1. 3.x modules/book.views.inc
  2. 2.x modules/book.views.inc

Provide views data and handlers for book.module

File

modules/book.views.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provide views data and handlers for book.module
  5. */
  6. /**
  7. * @defgroup views_book_module book.module handlers
  8. *
  9. * @{
  10. */
  11. /**
  12. * Implementation of hook_views_data()
  13. */
  14. function book_views_data() {
  15. // ----------------------------------------------------------------------
  16. // book table
  17. $data['book']['table']['group'] = t('Book');
  18. $data['book']['table']['join'] = array(
  19. 'node' => array(
  20. 'left_field' => 'nid',
  21. 'field' => 'nid',
  22. ),
  23. );
  24. $data['book']['bid'] = array(
  25. 'title' => t('Top level book'),
  26. 'help' => t('The book the node is in.'),
  27. 'relationship' => array(
  28. 'base' => 'node',
  29. 'handler' => 'views_handler_relationship',
  30. 'label' => t('Book'),
  31. ),
  32. // There is no argument here; if you need an argument, add the relationship
  33. // and use the node: nid argument.
  34. );
  35. // ----------------------------------------------------------------------
  36. // menu_links table -- this is aliased so we can get just book relations
  37. // Book hierarchy and weight data are now in {menu_links}.
  38. $data['book_menu_links']['table']['group'] = t('Book');
  39. $data['book_menu_links']['table']['join'] = array(
  40. 'node' => array(
  41. 'table' => 'menu_links',
  42. 'left_table' => 'book',
  43. 'left_field' => 'mlid',
  44. 'field' => 'mlid',
  45. ),
  46. );
  47. $data['book_menu_links']['weight'] = array(
  48. 'title' => t('Weight'),
  49. 'help' => t('The weight of the book page.'),
  50. 'field' => array(
  51. 'handler' => 'views_handler_field_numeric',
  52. 'click sortable' => TRUE,
  53. ),
  54. 'sort' => array(
  55. 'handler' => 'views_handler_sort',
  56. ),
  57. );
  58. $data['book_menu_links']['depth'] = array(
  59. 'title' => t('Depth'),
  60. 'help' => t('The depth of the book page in the hierarchy; top level books have a depth of 1.'),
  61. 'field' => array(
  62. 'handler' => 'views_handler_field_numeric',
  63. 'click sortable' => TRUE,
  64. ),
  65. 'sort' => array(
  66. 'handler' => 'views_handler_sort',
  67. ),
  68. 'filter' => array(
  69. 'handler' => 'views_handler_filter_numeric',
  70. ),
  71. 'argument' => array(
  72. 'handler' => 'views_handler_argument',
  73. ),
  74. );
  75. $data['book_menu_links']['p'] = array(
  76. 'title' => t('Hierarchy'),
  77. 'help' => t('The order of pages in the book hierarchy.'),
  78. 'sort' => array(
  79. 'handler' => 'views_handler_sort_menu_hierarchy',
  80. ),
  81. );
  82. // ----------------------------------------------------------------------
  83. // book_parent table -- this is an alias of the book table which
  84. // represents the parent book.
  85. // The {book} record for the parent node.
  86. $data['book_parent']['table']['group'] = t('Book');
  87. $data['book_parent']['table']['join'] = array(
  88. 'node' => array(
  89. 'table' => 'book',
  90. 'left_table' => 'book_menu_links',
  91. 'left_field' => 'plid',
  92. 'field' => 'mlid',
  93. ),
  94. );
  95. $data['book_parent']['nid'] = array(
  96. 'title' => t('Parent'),
  97. 'help' => t('The parent book node.'),
  98. 'relationship' => array(
  99. 'base' => 'node',
  100. 'base field' => 'nid',
  101. 'handler' => 'views_handler_relationship',
  102. 'label' => t('Book parent'),
  103. ),
  104. );
  105. return $data;
  106. }
  107. /**
  108. * @}
  109. */