Basic node.created summaries for archive view
[project/views.git] / theme / theme.inc
1 <?php
2 // $Id$
3
4 /**
5 * Preprocess the primary theme implementation for a view.
6 */
7 function template_preprocess_views_view(&$vars) {
8 $view = $vars['view'];
9
10 $vars['rows'] = $view->style_handler->render($view->result);
11 $vars['css_name'] = views_css_safe($view->name);
12
13 if (!$vars['rows']) {
14 $vars['empty'] = $view->display_handler->render_empty();
15 }
16 else {
17 $vars['empty'] = '';
18 }
19
20 $vars['filters'] = $view->display_handler->render_filters();
21 $vars['header'] = $view->display_handler->render_header();
22 $vars['footer'] = $view->display_handler->render_footer();
23 $vars['more'] = $view->display_handler->render_more_link();
24 $vars['feed_icon'] = $view->display_handler->render_feed_icon();
25
26 $vars['pager'] = '';
27 if (!empty($view->use_pager)) {
28 $vars['pager'] = theme('pager', array(), $view->page_size, $view->page_element);
29 }
30
31 }
32
33 /**
34 * Preprocess theme function to print a single record from a row, with fields
35 */
36 function template_preprocess_views_view_fields(&$vars) {
37 $view = $vars['view'];
38
39 // Loop through the fields for this view.
40 foreach ($view->field as $field) {
41 if (!empty($field->handler) && is_object($field->handler)) {
42 $themes = array(
43 'views_view_field__' . $view->name . '__' . $field->handler->field_alias,
44 'views_view_field__' . $view->name,
45 'views_view_field__' . $field->handler->field_alias,
46 'views_view_field',
47 );
48 // Add the field into a variable named after the field. field_alias will be unique.
49 $vars[$field->handler->field_alias] = theme($themes, $view, $field, $vars['row']);
50 // Create a second variable so we can easily find what fields we have and what the
51 // CSS classes should be.
52 $vars['fields'][$field->handler->field_alias] = views_css_safe($field->handler->field_alias);
53 }
54 }
55 }
56
57 /**
58 * Display a single views field.
59 *
60 * Interesting bits of info:
61 * $field->field_alias says what the raw value in $row will be. Reach it like
62 * this: @code { $row->{$field->field_alias} @endcode
63 */
64 function theme_views_view_field($view, $field, $row) {
65 return $field->handler->render($row);
66 }
67
68 /**
69 * Preprocess theme function to print a single record from a row, with fields
70 */
71 function template_preprocess_views_view_summary(&$vars) {
72 $view = $vars['view'];
73 $argument = $view->argument[$view->build_info['summary_level']]->handler;
74
75 foreach ($vars['rows'] as $id => $row) {
76 $vars['rows'][$id]->link = $argument->summary_name($row);
77 $vars['rows'][$id]->url = $argument->summary_link($row, $view->get_url());
78 $vars['rows'][$id]->count = intval($row->{$argument->count_alias});
79 }
80 }
81
82 /**
83 * @defgroup views_templates Views' template files
84 */