Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding default empty text to views that don't have empty text defined.

  • Loading branch information...
commit 19e3db7ac979909f372bc465a659789ac884e60f 1 parent b73216b
@jhedstrom jhedstrom authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 os_base.module
View
22 os_base.module
@@ -167,3 +167,25 @@ function os_base_preprocess_block(&$vars) {
$vars['classes_array'][] = 'dropdown-block';
}
}
+
+/**
+ * Preprocessor for theme('views_view').
+ */
+function os_base_preprocess_views_view(&$vars) {
+ $view = $vars['view'];
+ if ($view->base_table === 'node' && strpos($view->current_display, 'page') !== FALSE && empty($view->result) && empty($vars['empty'])) {
+ $types = node_type_get_types();
+ foreach ($view->filter as $handler) {
+ if ($handler->table === 'node' && $handler->field === 'type' && !empty($handler->options['value'])) {
+ foreach (array_filter($handler->options['value']) as $type) {
+ $item = menu_get_item('node/add/'. strtr($type, array('_' => '-')));
+ if ($item && $item['access']) {
+ $output = t('Please <a href="!url">add your first @type</a> to get started.', array('@type' => $types[$type]->name, '!url' => url('node/add/' . $type)));
+ }
+ }
+ break;
+ }
+ }
+ $vars['empty'] = !empty($output) ? $output : t('There is currently no content to view in this section.');
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.