faq.views.inc 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * Implements hook_views_data().
  4. */
  5. function faq_views_data() {
  6. // faq_questions table.
  7. $data['faq_questions']['table']['group'] = t('FAQ');
  8. $data['faq_questions']['table']['join'] = array(
  9. 'node' => array(
  10. 'left_field' => 'nid',
  11. 'field' => 'nid',
  12. ),
  13. );
  14. $data['faq_questions']['question'] = array(
  15. 'title' => t('FAQ short question'),
  16. 'help' => t('The short question text for FAQ nodes.'),
  17. 'field' => array(
  18. 'handler' => 'views_handler_field',
  19. 'click sortable' => TRUE,
  20. ),
  21. 'sort' => array(
  22. 'handler' => 'views_handler_sort',
  23. ),
  24. 'filter' => array(
  25. 'handler' => 'views_handler_filter_string',
  26. ),
  27. );
  28. $data['faq_questions']['detailed_question'] = array(
  29. 'title' => t('FAQ detailed question'),
  30. 'help' => t('The long question text for FAQ nodes.'),
  31. 'field' => array(
  32. 'handler' => 'views_handler_field',
  33. 'click sortable' => TRUE,
  34. ),
  35. 'sort' => array(
  36. 'handler' => 'views_handler_sort',
  37. ),
  38. 'filter' => array(
  39. 'handler' => 'views_handler_filter_string',
  40. ),
  41. );
  42. // faq_weights table.
  43. $data['faq_weights']['table']['group'] = t('FAQ');
  44. $data['faq_weights']['table']['join'] = array(
  45. 'node' => array(
  46. 'left_field' => 'nid',
  47. 'field' => 'nid',
  48. ),
  49. 'taxonomy_term_data' => array(
  50. 'left_field' => 'tid',
  51. 'field' => 'tid',
  52. ),
  53. );
  54. $data['faq_weights']['weight'] = array(
  55. 'title' => t('FAQ weight'),
  56. 'help' => t('The weight of the FAQ node.'),
  57. 'field' => array(
  58. 'handler' => 'views_handler_field_numeric',
  59. 'click sortable' => TRUE,
  60. ),
  61. 'sort' => array(
  62. 'handler' => 'views_handler_sort',
  63. ),
  64. 'filter' => array(
  65. 'handler' => 'views_handler_filter_numeric',
  66. ),
  67. );
  68. $data['faq_weights']['tid'] = array(
  69. 'title' => t('FAQ category tid'),
  70. 'help' => t('The tid of the FAQ node.'),
  71. 'field' => array(
  72. 'handler' => 'views_handler_field_numeric',
  73. 'click sortable' => TRUE,
  74. 'zero is null' => FALSE,
  75. ),
  76. 'filter' => array(
  77. 'title' => t('Tid'),
  78. 'handler' => 'views_handler_filter_numeric',
  79. 'hierarchy table' => 'taxonomy_term_hierarchy',
  80. 'numeric' => TRUE,
  81. 'skip base' => 'taxonomy_term_data',
  82. 'allow empty' => TRUE,
  83. 'zero is null' => FALSE,
  84. ),
  85. 'relationship' => array(
  86. 'handler' => 'views_handler_relationship',
  87. 'label' => t('category'),
  88. 'base' => 'taxonomy_index',
  89. 'base field' => 'tid',
  90. 'skip base' => 'taxonomy_term_data',
  91. ),
  92. );
  93. $data['faq_weights']['category'] = array(
  94. 'title' => t('FAQ category'),
  95. 'help' => t('The term of the FAQ node.'),
  96. 'real field' => 'tid',
  97. 'field' => array(
  98. 'handler' => 'views_handler_field_term_node_tid',
  99. 'click sortable' => TRUE,
  100. 'zero is null' => TRUE,
  101. ),
  102. 'argument' => array(
  103. 'handler' => 'views_handler_argument_term_node_tid',
  104. 'name table' => 'taxonomy_term_data',
  105. 'name field' => 'name',
  106. 'empty field name' => t('Uncategorized'),
  107. 'numeric' => TRUE,
  108. 'skip base' => 'taxonomy_term_data',
  109. 'zero is null' => TRUE,
  110. ),
  111. 'filter' => array(
  112. 'title' => t('Term'),
  113. 'handler' => 'views_handler_filter_term_node_tid',
  114. 'hierarchy table' => 'taxonomy_term_hierarchy',
  115. 'numeric' => TRUE,
  116. 'skip base' => 'taxonomy_term_data',
  117. 'allow empty' => TRUE,
  118. 'zero is null' => FALSE,
  119. ),
  120. );
  121. return $data;
  122. }