views_plugin_argument_default_book_root.inc 567 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_argument_default_book_root.
  5. */
  6. /**
  7. * Default argument plugin to get the current node's book root.
  8. */
  9. class views_plugin_argument_default_book_root extends views_plugin_argument_default_node {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function get_argument() {
  14. // Use the argument_default_node plugin to get the nid argument.
  15. $nid = parent::get_argument();
  16. if (!empty($nid)) {
  17. $node = node_load($nid);
  18. if (isset($node->book['bid'])) {
  19. return $node->book['bid'];
  20. }
  21. }
  22. }
  23. }