1 | <?php |
---|
2 | /** |
---|
3 | * @file |
---|
4 | * This file contains no working PHP code; it exists to provide additional documentation |
---|
5 | * for doxygen as well as to document hooks in the standard Drupal manner. |
---|
6 | */ |
---|
7 | |
---|
8 | /** |
---|
9 | * @mainpage Views 2 API Manual |
---|
10 | * |
---|
11 | * Much of this information is actually stored in the advanced help; please |
---|
12 | * check the API topic. This help will primarily be aimed at documenting |
---|
13 | * classes and function calls. |
---|
14 | * |
---|
15 | * An online version of the advanced help API documentation is available from: |
---|
16 | * @link http://views-help.doc.logrus.com/help/views/api @endlink |
---|
17 | * |
---|
18 | * Topics: |
---|
19 | * - @ref view_lifetime |
---|
20 | * - @ref views_hooks |
---|
21 | * - @ref views_handlers |
---|
22 | * - @ref views_plugins |
---|
23 | * - @ref views_templates |
---|
24 | */ |
---|
25 | |
---|
26 | /** |
---|
27 | * @page view_lifetime The life of a view |
---|
28 | * |
---|
29 | * This page explains the basic cycle of a view and what processes happen. |
---|
30 | */ |
---|
31 | |
---|
32 | /** |
---|
33 | * @page views_handlers About Views' handlers |
---|
34 | * |
---|
35 | * This page explains what views handlers are, how they're written, and what |
---|
36 | * the basic conventions are. |
---|
37 | * |
---|
38 | * - @ref views_field_handlers |
---|
39 | * - @ref views_sort_handlers |
---|
40 | * - @ref views_filter_handlers |
---|
41 | * - @ref views_argument_handlers |
---|
42 | * - @ref views_relationship_handlers |
---|
43 | */ |
---|
44 | |
---|
45 | /** |
---|
46 | * @page views_plugins About Views' plugins |
---|
47 | * |
---|
48 | * This page explains what views plugins are, how they're written, and what |
---|
49 | * the basic conventions are. |
---|
50 | * |
---|
51 | * - @ref views_display_plugins |
---|
52 | * - @ref views_style_plugins |
---|
53 | * - @ref views_row_plugins |
---|
54 | */ |
---|
55 | |
---|
56 | /** |
---|
57 | * @defgroup views_hooks Views' hooks |
---|
58 | * @{ |
---|
59 | * Hooks that can be implemented by other modules in order to implement the |
---|
60 | * Views API. |
---|
61 | */ |
---|
62 | |
---|
63 | /** |
---|
64 | * Describe table structure to Views. |
---|
65 | * |
---|
66 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
67 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
68 | * named 'includes'. |
---|
69 | * |
---|
70 | * The full documentation for this hook is in the advanced help. |
---|
71 | * @link http://views-help.doc.logrus.com/help/views/api-tables @endlink |
---|
72 | */ |
---|
73 | function hook_views_data() { |
---|
74 | // This example describes how to write hook_views_data() for the following |
---|
75 | // table: |
---|
76 | // |
---|
77 | // CREATE TABLE example_table ( |
---|
78 | // nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.', |
---|
79 | // plain_text_field VARCHAR(32) COMMENT 'Just a plain text field.', |
---|
80 | // numeric_field INT(11) COMMENT 'Just a numeric field.', |
---|
81 | // boolean_field INT(1) COMMENT 'Just an on/off field.', |
---|
82 | // timestamp_field INT(8) COMMENT 'Just a timestamp field.', |
---|
83 | // PRIMARY KEY(nid) |
---|
84 | // ); |
---|
85 | |
---|
86 | // The 'group' index will be used as a prefix in the UI for any of this |
---|
87 | // table's fields, sort criteria, etc. so it's easy to tell where they came |
---|
88 | // from. |
---|
89 | $data['example_table']['table']['group'] = t('Example table'); |
---|
90 | |
---|
91 | // Define this as a base table. In reality this is not very useful for |
---|
92 | // this table, as it isn't really a distinct object of its own, but |
---|
93 | // it makes a good example. |
---|
94 | $data['example_table']['table']['base'] = array( |
---|
95 | 'field' => 'nid', |
---|
96 | 'title' => t('Example table'), |
---|
97 | 'help' => t("Example table contains example content and can be related to nodes."), |
---|
98 | 'weight' => -10, |
---|
99 | ); |
---|
100 | |
---|
101 | // This table references the {node} table. |
---|
102 | // This creates an 'implicit' relationship to the node table, so that when 'Node' |
---|
103 | // is the base table, the fields are automatically available. |
---|
104 | $data['example_table']['table']['join'] = array( |
---|
105 | // Index this array by the table name to which this table refers. |
---|
106 | // 'left_field' is the primary key in the referenced table. |
---|
107 | // 'field' is the foreign key in this table. |
---|
108 | 'node' => array( |
---|
109 | 'left_field' => 'nid', |
---|
110 | 'field' => 'nid', |
---|
111 | ), |
---|
112 | ); |
---|
113 | |
---|
114 | // Next, describe each of the individual fields in this table to Views. For |
---|
115 | // each field, you may define what field, sort, argument, and/or filter |
---|
116 | // handlers it supports. This will determine where in the Views interface you |
---|
117 | // may use the field. |
---|
118 | |
---|
119 | // Node ID field. |
---|
120 | $data['example_table']['nid'] = array( |
---|
121 | 'title' => t('Example content'), |
---|
122 | 'help' => t('Some example content that references a node.'), |
---|
123 | // Because this is a foreign key to the {node} table. This allows us to |
---|
124 | // have, when the view is configured with this relationship, all the fields |
---|
125 | // for the related node available. |
---|
126 | 'relationship' => array( |
---|
127 | 'base' => 'node', |
---|
128 | 'field' => 'nid', |
---|
129 | 'handler' => 'views_handler_relationship', |
---|
130 | 'label' => t('Example node'), |
---|
131 | ), |
---|
132 | ); |
---|
133 | |
---|
134 | // Example plain text field. |
---|
135 | $data['example_table']['plain_text_field'] = array( |
---|
136 | 'title' => t('Plain text field'), |
---|
137 | 'help' => t('Just a plain text field.'), |
---|
138 | 'field' => array( |
---|
139 | 'handler' => 'views_handler_field', |
---|
140 | 'click sortable' => TRUE, |
---|
141 | ), |
---|
142 | 'sort' => array( |
---|
143 | 'handler' => 'views_handler_sort', |
---|
144 | ), |
---|
145 | 'filter' => array( |
---|
146 | 'handler' => 'views_handler_filter_string', |
---|
147 | ), |
---|
148 | 'argument' => array( |
---|
149 | 'handler' => 'views_handler_argument_string', |
---|
150 | ), |
---|
151 | ); |
---|
152 | |
---|
153 | // Example numeric text field. |
---|
154 | $data['example_table']['numeric_field'] = array( |
---|
155 | 'title' => t('Numeric field'), |
---|
156 | 'help' => t('Just a numeric field.'), |
---|
157 | 'field' => array( |
---|
158 | 'handler' => 'views_handler_field_numeric', |
---|
159 | 'click sortable' => TRUE, |
---|
160 | ), |
---|
161 | 'filter' => array( |
---|
162 | 'handler' => 'views_handler_filter_numeric', |
---|
163 | ), |
---|
164 | 'sort' => array( |
---|
165 | 'handler' => 'views_handler_sort', |
---|
166 | ), |
---|
167 | ); |
---|
168 | |
---|
169 | // Example boolean field. |
---|
170 | $data['example_table']['boolean_field'] = array( |
---|
171 | 'title' => t('Boolean field'), |
---|
172 | 'help' => t('Just an on/off field.'), |
---|
173 | 'field' => array( |
---|
174 | 'handler' => 'views_handler_field_boolean', |
---|
175 | 'click sortable' => TRUE, |
---|
176 | ), |
---|
177 | 'filter' => array( |
---|
178 | 'handler' => 'views_handler_filter_boolean_operator', |
---|
179 | 'label' => t('Published'), |
---|
180 | 'type' => 'yes-no', |
---|
181 | // use boolean_field = 1 instead of boolean_field <> 0 in WHERE statment |
---|
182 | 'use equal' => TRUE, |
---|
183 | ), |
---|
184 | 'sort' => array( |
---|
185 | 'handler' => 'views_handler_sort', |
---|
186 | ), |
---|
187 | ); |
---|
188 | |
---|
189 | // Example timestamp field. |
---|
190 | $data['example_table']['timestamp_field'] = array( |
---|
191 | 'title' => t('Timestamp field'), |
---|
192 | 'help' => t('Just a timestamp field.'), |
---|
193 | 'field' => array( |
---|
194 | 'handler' => 'views_handler_field_date', |
---|
195 | 'click sortable' => TRUE, |
---|
196 | ), |
---|
197 | 'sort' => array( |
---|
198 | 'handler' => 'views_handler_sort_date', |
---|
199 | ), |
---|
200 | 'filter' => array( |
---|
201 | 'handler' => 'views_handler_filter_date', |
---|
202 | ), |
---|
203 | ); |
---|
204 | |
---|
205 | return $data; |
---|
206 | } |
---|
207 | |
---|
208 | /** |
---|
209 | * Alter table structure. |
---|
210 | * |
---|
211 | * You can add/edit/remove to existing tables defined by hook_views_data(). |
---|
212 | * |
---|
213 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
214 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
215 | * named 'includes'. |
---|
216 | * |
---|
217 | * The full documentation for this hook is in the advanced help. |
---|
218 | * @link http://views-help.doc.logrus.com/help/views/api-tables @endlink |
---|
219 | */ |
---|
220 | function hook_views_data_alter(&$data) { |
---|
221 | // This example alters the title of the node: nid field for the admin. |
---|
222 | $data['node']['nid']['title'] = t('Node-Nid'); |
---|
223 | |
---|
224 | // This example adds a example field to the users table |
---|
225 | $data['users']['example_field'] = array( |
---|
226 | 'title' => t('Example field'), |
---|
227 | 'help' => t('Some examÃŒple content that references a user'), |
---|
228 | 'handler' => 'hook_handlers_field_example_field', |
---|
229 | ); |
---|
230 | |
---|
231 | // This example changes the handler of the node title field. |
---|
232 | // In this handler you could do stuff, like preview of the node, when clicking the node title. |
---|
233 | |
---|
234 | $data['node']['title']['handler'] = 'modulename_handlers_field_node_title'; |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | /** |
---|
239 | * The full documentation for this hook is now in the advanced help. |
---|
240 | * |
---|
241 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
242 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
243 | * named 'includes'. |
---|
244 | * |
---|
245 | * This is a stub list as a reminder that this needs to be doc'd and is not used |
---|
246 | * in views anywhere so might not be remembered when this is formally documented: |
---|
247 | * - style: 'even empty' |
---|
248 | */ |
---|
249 | function hook_views_plugins() { |
---|
250 | // example code here |
---|
251 | } |
---|
252 | |
---|
253 | /** |
---|
254 | * Alter existing plugins data, defined by modules. |
---|
255 | */ |
---|
256 | function hook_views_plugins_alter(&$plugins) { |
---|
257 | // Add apachesolr to the base of the node row plugin. |
---|
258 | $plugins['row']['node']['base'][] = 'apachesolr'; |
---|
259 | } |
---|
260 | |
---|
261 | /** |
---|
262 | * Register handler, file and parent information so that handlers can be |
---|
263 | * loaded only on request. |
---|
264 | * |
---|
265 | * The full documentation for this hook is in the advanced help. |
---|
266 | */ |
---|
267 | function hook_views_handlers() { |
---|
268 | // example code here |
---|
269 | } |
---|
270 | |
---|
271 | /** |
---|
272 | * Register View API information. This is required for your module to have |
---|
273 | * its include files loaded; for example, when implementing |
---|
274 | * hook_views_default_views(). |
---|
275 | * |
---|
276 | * @return |
---|
277 | * An array with the following possible keys: |
---|
278 | * - api: (required) The version of the Views API the module implements. |
---|
279 | * - path: (optional) If includes are stored somewhere other than within |
---|
280 | * the root module directory or a subdirectory called includes, specify |
---|
281 | * its path here. |
---|
282 | * - template path: (optional) A path where the module has stored it's views template files. |
---|
283 | * When you have specificed this key views automatically uses the template files for the views. |
---|
284 | * You can use the same naming conventions like for normal views template files. |
---|
285 | */ |
---|
286 | function hook_views_api() { |
---|
287 | return array( |
---|
288 | 'api' => 2, |
---|
289 | 'path' => drupal_get_path('module', 'example') . '/includes/views', |
---|
290 | 'template path' => drupal_get_path('module', 'example') . 'themes', |
---|
291 | ); |
---|
292 | } |
---|
293 | |
---|
294 | /** |
---|
295 | * This hook allows modules to provide their own views which can either be used |
---|
296 | * as-is or as a "starter" for users to build from. |
---|
297 | * |
---|
298 | * The hook should be placed in MODULENAME.views_default.inc and it will be |
---|
299 | * auto-loaded. This must either be in the same directory as the .module file |
---|
300 | * or in a subdirectory named 'includes'. |
---|
301 | * |
---|
302 | * This hook requires an array of views, where each array has key/value pair and must |
---|
303 | * have $value == $view->name, it is invalid if the keys not match. |
---|
304 | * |
---|
305 | * The $view->disabled boolean flag indicates whether the View should be |
---|
306 | * enabled or disabled by default. |
---|
307 | * |
---|
308 | * |
---|
309 | * @return |
---|
310 | * An associative array containing the structures of views, as generated from |
---|
311 | * the Export tab, keyed by the view name. A best practice is to go through |
---|
312 | * and add t() to all title and label strings, with the exception of menu |
---|
313 | * strings. |
---|
314 | */ |
---|
315 | function hook_views_default_views() { |
---|
316 | // Begin copy and paste of output from the Export tab of a view. |
---|
317 | $view = new view; |
---|
318 | $view->name = 'frontpage'; |
---|
319 | $view->description = t('Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'); |
---|
320 | $view->tag = t('default'); |
---|
321 | $view->base_table = 'node'; |
---|
322 | $view->api_version = 2; |
---|
323 | $view->disabled = FALSE; // Edit this to true to make a default view disabled initially |
---|
324 | $view->display = array(); |
---|
325 | $display = new views_display; |
---|
326 | $display->id = 'default'; |
---|
327 | $display->display_title = t('Defaults'); |
---|
328 | $display->display_plugin = 'default'; |
---|
329 | $display->position = '1'; |
---|
330 | $display->display_options = array ( |
---|
331 | 'style_plugin' => 'default', |
---|
332 | 'style_options' => |
---|
333 | array ( |
---|
334 | ), |
---|
335 | 'row_plugin' => 'node', |
---|
336 | 'row_options' => |
---|
337 | array ( |
---|
338 | 'teaser' => 1, |
---|
339 | 'links' => 1, |
---|
340 | ), |
---|
341 | 'relationships' => |
---|
342 | array ( |
---|
343 | ), |
---|
344 | 'fields' => |
---|
345 | array ( |
---|
346 | ), |
---|
347 | 'sorts' => |
---|
348 | array ( |
---|
349 | 'sticky' => |
---|
350 | array ( |
---|
351 | 'id' => 'sticky', |
---|
352 | 'table' => 'node', |
---|
353 | 'field' => 'sticky', |
---|
354 | 'order' => 'ASC', |
---|
355 | ), |
---|
356 | 'created' => |
---|
357 | array ( |
---|
358 | 'id' => 'created', |
---|
359 | 'table' => 'node', |
---|
360 | 'field' => 'created', |
---|
361 | 'order' => 'ASC', |
---|
362 | 'relationship' => 'none', |
---|
363 | 'granularity' => 'second', |
---|
364 | ), |
---|
365 | ), |
---|
366 | 'arguments' => |
---|
367 | array ( |
---|
368 | ), |
---|
369 | 'filters' => |
---|
370 | array ( |
---|
371 | 'promote' => |
---|
372 | array ( |
---|
373 | 'id' => 'promote', |
---|
374 | 'table' => 'node', |
---|
375 | 'field' => 'promote', |
---|
376 | 'operator' => '=', |
---|
377 | 'value' => '1', |
---|
378 | 'group' => 0, |
---|
379 | 'exposed' => false, |
---|
380 | 'expose' => |
---|
381 | array ( |
---|
382 | 'operator' => false, |
---|
383 | 'label' => '', |
---|
384 | ), |
---|
385 | ), |
---|
386 | 'status' => |
---|
387 | array ( |
---|
388 | 'id' => 'status', |
---|
389 | 'table' => 'node', |
---|
390 | 'field' => 'status', |
---|
391 | 'operator' => '=', |
---|
392 | 'value' => '1', |
---|
393 | 'group' => 0, |
---|
394 | 'exposed' => false, |
---|
395 | 'expose' => |
---|
396 | array ( |
---|
397 | 'operator' => false, |
---|
398 | 'label' => '', |
---|
399 | ), |
---|
400 | ), |
---|
401 | ), |
---|
402 | 'items_per_page' => 10, |
---|
403 | 'use_pager' => '1', |
---|
404 | 'pager_element' => 0, |
---|
405 | 'title' => '', |
---|
406 | 'header' => '', |
---|
407 | 'header_format' => '1', |
---|
408 | 'footer' => '', |
---|
409 | 'footer_format' => '1', |
---|
410 | 'empty' => '', |
---|
411 | 'empty_format' => '1', |
---|
412 | ); |
---|
413 | $view->display['default'] = $display; |
---|
414 | $display = new views_display; |
---|
415 | $display->id = 'page'; |
---|
416 | $display->display_title = t('Page'); |
---|
417 | $display->display_plugin = 'page'; |
---|
418 | $display->position = '2'; |
---|
419 | $display->display_options = array ( |
---|
420 | 'defaults' => |
---|
421 | array ( |
---|
422 | 'access' => true, |
---|
423 | 'title' => true, |
---|
424 | 'header' => true, |
---|
425 | 'header_format' => true, |
---|
426 | 'header_empty' => true, |
---|
427 | 'footer' => true, |
---|
428 | 'footer_format' => true, |
---|
429 | 'footer_empty' => true, |
---|
430 | 'empty' => true, |
---|
431 | 'empty_format' => true, |
---|
432 | 'items_per_page' => true, |
---|
433 | 'offset' => true, |
---|
434 | 'use_pager' => true, |
---|
435 | 'pager_element' => true, |
---|
436 | 'link_display' => true, |
---|
437 | 'php_arg_code' => true, |
---|
438 | 'exposed_options' => true, |
---|
439 | 'style_plugin' => true, |
---|
440 | 'style_options' => true, |
---|
441 | 'row_plugin' => true, |
---|
442 | 'row_options' => true, |
---|
443 | 'relationships' => true, |
---|
444 | 'fields' => true, |
---|
445 | 'sorts' => true, |
---|
446 | 'arguments' => true, |
---|
447 | 'filters' => true, |
---|
448 | 'use_ajax' => true, |
---|
449 | 'distinct' => true, |
---|
450 | ), |
---|
451 | 'relationships' => |
---|
452 | array ( |
---|
453 | ), |
---|
454 | 'fields' => |
---|
455 | array ( |
---|
456 | ), |
---|
457 | 'sorts' => |
---|
458 | array ( |
---|
459 | ), |
---|
460 | 'arguments' => |
---|
461 | array ( |
---|
462 | ), |
---|
463 | 'filters' => |
---|
464 | array ( |
---|
465 | ), |
---|
466 | 'path' => 'frontpage', |
---|
467 | ); |
---|
468 | $view->display['page'] = $display; |
---|
469 | $display = new views_display; |
---|
470 | $display->id = 'feed'; |
---|
471 | $display->display_title = t('Feed'); |
---|
472 | $display->display_plugin = 'feed'; |
---|
473 | $display->position = '3'; |
---|
474 | $display->display_options = array ( |
---|
475 | 'defaults' => |
---|
476 | array ( |
---|
477 | 'access' => true, |
---|
478 | 'title' => false, |
---|
479 | 'header' => true, |
---|
480 | 'header_format' => true, |
---|
481 | 'header_empty' => true, |
---|
482 | 'footer' => true, |
---|
483 | 'footer_format' => true, |
---|
484 | 'footer_empty' => true, |
---|
485 | 'empty' => true, |
---|
486 | 'empty_format' => true, |
---|
487 | 'use_ajax' => true, |
---|
488 | 'items_per_page' => true, |
---|
489 | 'offset' => true, |
---|
490 | 'use_pager' => true, |
---|
491 | 'pager_element' => true, |
---|
492 | 'use_more' => true, |
---|
493 | 'distinct' => true, |
---|
494 | 'link_display' => true, |
---|
495 | 'php_arg_code' => true, |
---|
496 | 'exposed_options' => true, |
---|
497 | 'style_plugin' => false, |
---|
498 | 'style_options' => false, |
---|
499 | 'row_plugin' => false, |
---|
500 | 'row_options' => false, |
---|
501 | 'relationships' => true, |
---|
502 | 'fields' => true, |
---|
503 | 'sorts' => true, |
---|
504 | 'arguments' => true, |
---|
505 | 'filters' => true, |
---|
506 | ), |
---|
507 | 'relationships' => |
---|
508 | array ( |
---|
509 | ), |
---|
510 | 'fields' => |
---|
511 | array ( |
---|
512 | ), |
---|
513 | 'sorts' => |
---|
514 | array ( |
---|
515 | ), |
---|
516 | 'arguments' => |
---|
517 | array ( |
---|
518 | ), |
---|
519 | 'filters' => |
---|
520 | array ( |
---|
521 | ), |
---|
522 | 'displays' => |
---|
523 | array ( |
---|
524 | 'default' => 'default', |
---|
525 | 'page' => 'page', |
---|
526 | ), |
---|
527 | 'style_plugin' => 'rss', |
---|
528 | 'style_options' => |
---|
529 | array ( |
---|
530 | 'mission_description' => 1, |
---|
531 | 'description' => '', |
---|
532 | ), |
---|
533 | 'row_plugin' => 'node_rss', |
---|
534 | 'row_options' => |
---|
535 | array ( |
---|
536 | 'item_length' => 'default', |
---|
537 | ), |
---|
538 | 'path' => 'rss.xml', |
---|
539 | 'title' => t('Front page feed'), |
---|
540 | ); |
---|
541 | $view->display['feed'] = $display; |
---|
542 | // End copy and paste of Export tab output. |
---|
543 | |
---|
544 | // Add view to list of views to provide. |
---|
545 | $views[$view->name] = $view; |
---|
546 | |
---|
547 | // ...Repeat all of the above for each view the module should provide. |
---|
548 | |
---|
549 | // At the end, return array of default views. |
---|
550 | return $views; |
---|
551 | } |
---|
552 | |
---|
553 | /** |
---|
554 | * Alter default views defined by other modules. |
---|
555 | * |
---|
556 | * This hook is called right before all default views are cached to the |
---|
557 | * database. It takes a keyed array of views by reference. |
---|
558 | * |
---|
559 | * Example usage to add a field to a view: |
---|
560 | * @code |
---|
561 | * $handler =& $view->display['DISPLAY_ID']->handler; |
---|
562 | * // Add the user name field to the view. |
---|
563 | * $handler->display->display_options['fields']['name']['id'] = 'name'; |
---|
564 | * $handler->display->display_options['fields']['name']['table'] = 'users'; |
---|
565 | * $handler->display->display_options['fields']['name']['field'] = 'name'; |
---|
566 | * $handler->display->display_options['fields']['name']['label'] = 'Author'; |
---|
567 | * $handler->display->display_options['fields']['name']['link_to_user'] = 1; |
---|
568 | * @endcode |
---|
569 | */ |
---|
570 | function hook_views_default_views_alter(&$views) { |
---|
571 | if (isset($views['taxonomy_term'])) { |
---|
572 | $views['taxonomy_term']->display['default']->display_options['title'] = 'Categories'; |
---|
573 | } |
---|
574 | } |
---|
575 | |
---|
576 | /** |
---|
577 | * Stub hook documentation |
---|
578 | * |
---|
579 | * This hook should be placed in MODULENAME.views_convert.inc and it will be auto-loaded. |
---|
580 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
581 | * named 'includes'. |
---|
582 | */ |
---|
583 | function hook_views_convert() { |
---|
584 | // example code here |
---|
585 | } |
---|
586 | |
---|
587 | /** |
---|
588 | * Stub hook documentation |
---|
589 | */ |
---|
590 | function hook_views_query_substitutions() { |
---|
591 | // example code here |
---|
592 | } |
---|
593 | |
---|
594 | /** |
---|
595 | * This hook is called to get a list of placeholders and their substitutions, |
---|
596 | * used when preprocessing a View with form elements. |
---|
597 | */ |
---|
598 | function hook_views_form_substitutions() { |
---|
599 | return array( |
---|
600 | '<!--views-form-example-substitutions-->' => 'Example Substitution', |
---|
601 | ); |
---|
602 | } |
---|
603 | |
---|
604 | /** |
---|
605 | * Views form (View with form elements) validate handler. |
---|
606 | * Called for all steps ($form_state['storage']['step']) of the multistep form. |
---|
607 | */ |
---|
608 | function hook_views_form_validate($form, &$form_state) { |
---|
609 | // example code here |
---|
610 | } |
---|
611 | |
---|
612 | /** |
---|
613 | * Views form (View with form elements) submit handler. |
---|
614 | * Called for all steps ($form_state['storage']['step']) of the multistep form. |
---|
615 | */ |
---|
616 | function hook_views_form_submit($form, &$form_state) { |
---|
617 | // example code here |
---|
618 | } |
---|
619 | |
---|
620 | /** |
---|
621 | * This hook is called at the very beginning of views processing, |
---|
622 | * before anything is done. |
---|
623 | * |
---|
624 | * Adding output to the view can be accomplished by placing text on |
---|
625 | * $view->attachment_before and $view->attachment_after. |
---|
626 | */ |
---|
627 | function hook_views_pre_view(&$view, &$display_id, &$args) { |
---|
628 | // example code here |
---|
629 | } |
---|
630 | |
---|
631 | /** |
---|
632 | * This hook is called right before the build process, but after displays |
---|
633 | * are attached and the display performs its pre_execute phase. |
---|
634 | * |
---|
635 | * Adding output to the view can be accomplished by placing text on |
---|
636 | * $view->attachment_before and $view->attachment_after. |
---|
637 | */ |
---|
638 | function hook_views_pre_build(&$view) { |
---|
639 | // example code here |
---|
640 | } |
---|
641 | |
---|
642 | /** |
---|
643 | * This hook is called right after the build process. The query is |
---|
644 | * now fully built, but it has not yet been run through db_rewrite_sql. |
---|
645 | * |
---|
646 | * Adding output to the view can be accomplished by placing text on |
---|
647 | * $view->attachment_before and $view->attachment_after. |
---|
648 | */ |
---|
649 | function hook_views_post_build(&$view) { |
---|
650 | // example code here |
---|
651 | } |
---|
652 | |
---|
653 | /** |
---|
654 | * This hook is called right before the execute process. The query is |
---|
655 | * now fully built, but it has not yet been run through db_rewrite_sql. |
---|
656 | * |
---|
657 | * Adding output to the view can be accomplished by placing text on |
---|
658 | * $view->attachment_before and $view->attachment_after. |
---|
659 | */ |
---|
660 | function hook_views_pre_execute(&$view) { |
---|
661 | // example code here |
---|
662 | } |
---|
663 | |
---|
664 | /** |
---|
665 | * This hook is called right after the execute process. The query has |
---|
666 | * been executed, but the pre_render() phase has not yet happened for |
---|
667 | * handlers. |
---|
668 | * |
---|
669 | * Adding output to the view can be accomplished by placing text on |
---|
670 | * $view->attachment_before and $view->attachment_after. Altering the |
---|
671 | * content can be achieved by editing the items of $view->result. |
---|
672 | */ |
---|
673 | function hook_views_post_execute(&$view) { |
---|
674 | // example code here |
---|
675 | } |
---|
676 | |
---|
677 | /** |
---|
678 | * This hook is called right before the render process. The query has |
---|
679 | * been executed, and the pre_render() phase has already happened for |
---|
680 | * handlers, so all data should be available. |
---|
681 | * |
---|
682 | * Adding output to the view can be accomplished by placing text on |
---|
683 | * $view->attachment_before and $view->attachment_after. Altering the |
---|
684 | * content can be achieved by editing the items of $view->result. |
---|
685 | * |
---|
686 | * This hook can be utilized by themes. |
---|
687 | */ |
---|
688 | function hook_views_pre_render(&$view) { |
---|
689 | // example code here |
---|
690 | } |
---|
691 | |
---|
692 | /** |
---|
693 | * Post process any rendered data. |
---|
694 | * |
---|
695 | * This can be valuable to be able to cache a view and still have some level of |
---|
696 | * dynamic output. In an ideal world, the actual output will include HTML |
---|
697 | * comment based tokens, and then the post process can replace those tokens. |
---|
698 | * |
---|
699 | * Example usage. If it is known that the view is a node view and that the |
---|
700 | * primary field will be a nid, you can do something like this: |
---|
701 | * |
---|
702 | * <!--post-FIELD-NID--> |
---|
703 | * |
---|
704 | * And then in the post render, create an array with the text that should |
---|
705 | * go there: |
---|
706 | * |
---|
707 | * strtr($output, array('<!--post-FIELD-1-->', 'output for FIELD of nid 1'); |
---|
708 | * |
---|
709 | * All of the cached result data will be available in $view->result, as well, |
---|
710 | * so all ids used in the query should be discoverable. |
---|
711 | * |
---|
712 | * This hook can be utilized by themes. |
---|
713 | */ |
---|
714 | function hook_views_post_render(&$view, &$output, &$cache) { |
---|
715 | |
---|
716 | } |
---|
717 | |
---|
718 | /** |
---|
719 | * Stub hook documentation |
---|
720 | * |
---|
721 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
722 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
723 | * named 'includes'. |
---|
724 | * |
---|
725 | */ |
---|
726 | function hook_views_query_alter(&$view, &$query) { |
---|
727 | // example code here |
---|
728 | } |
---|
729 | |
---|
730 | /** |
---|
731 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
732 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
733 | * named 'includes'. |
---|
734 | * |
---|
735 | * Alter the links that appear over a view. They are in a format suitable for |
---|
736 | * theme('links'). |
---|
737 | * |
---|
738 | * Warning: $view is not a reference in PHP4 and cannot be modified here. But it IS |
---|
739 | * a reference in PHP5, and can be modified. Please be careful with it. |
---|
740 | * |
---|
741 | * @see theme_links |
---|
742 | */ |
---|
743 | function hook_views_admin_links_alter(&$links, $view) { |
---|
744 | // example code here |
---|
745 | } |
---|
746 | |
---|
747 | /** |
---|
748 | * This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
---|
749 | * This must either be in the same directory as the .module file or in a subdirectory |
---|
750 | * named 'includes'. |
---|
751 | * |
---|
752 | * Alter the rows that appear with a view, which includes path and query information. |
---|
753 | * The rows are suitable for theme('table'). |
---|
754 | * |
---|
755 | * Warning: $view is not a reference in PHP4 and cannot be modified here. But it IS |
---|
756 | * a reference in PHP5, and can be modified. Please be careful with it. |
---|
757 | * |
---|
758 | * @see theme_table |
---|
759 | */ |
---|
760 | function hook_views_preview_info_alter(&$rows, $view) { |
---|
761 | // example code here |
---|
762 | } |
---|
763 | |
---|
764 | /** |
---|
765 | * @} |
---|
766 | */ |
---|