page_title.views.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @file
  4. * Include file for Views hooks
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. *
  9. * Provides the Page Title as a Views field for Views 2.
  10. */
  11. function page_title_views_data() {
  12. $data = array();
  13. // Define the table.
  14. $data['page_title']['table']['group'] = t('Page Title');
  15. // Join the node table.
  16. $data['page_title']['table']['join'] = array(
  17. 'node' => array(
  18. 'table' => 'page_title',
  19. 'left_field' => 'nid',
  20. 'field' => 'id',
  21. 'extra' => array(
  22. array('field' => 'type', 'value' => 'node', 'operator' => '='),
  23. ),
  24. ),
  25. );
  26. // Define the field.
  27. $data['page_title']['page_title'] = array(
  28. 'title' => t('Title'),
  29. 'help' => t('A Page Title alternative to the Node: Title field.'),
  30. 'field' => array(
  31. 'field' => 'page_title', // The real field.
  32. 'group' => t('Page Title'), // The group it appears in on the UI.
  33. 'handler' => 'views_handler_field_node_page_title',
  34. 'click sortable' => TRUE,
  35. ),
  36. 'sort' => array(
  37. 'handler' => 'views_handler_sort',
  38. ),
  39. // Information for accepting a Page Title as a filter.
  40. 'filter' => array(
  41. 'handler' => 'views_handler_filter_string', // We can "borrow" the node handler.
  42. ),
  43. 'argument' => array(
  44. 'handler' => 'views_handler_argument_string', // We can "borrow" the node handler.
  45. ),
  46. );
  47. return $data;
  48. }
  49. /**
  50. * Implements hook_views_handlers().
  51. */
  52. function page_title_views_handlers() {
  53. return array(
  54. 'info' => array(
  55. 'path' => drupal_get_path('module', 'page_title'),
  56. ),
  57. 'handlers' => array(
  58. // field handlers
  59. 'views_handler_field_node_page_title' => array(
  60. 'parent' => 'views_handler_field',
  61. ),
  62. ),
  63. );
  64. }