-
Notifications
You must be signed in to change notification settings - Fork 2
/
luggage_blog.module
70 lines (60 loc) · 2.71 KB
/
luggage_blog.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @file
* Code for the Luggage Blog feature.
*/
include_once 'luggage_blog.features.inc';
/**
* Implements theme_preprocess_node()
*/
function luggage_blog_preprocess_node(&$vars) {
// Rewrite the display of the "Display author and date information" to be nicer for only
// blog posts.
if($vars['submitted'] && $vars['type'] == "lug_blog") {
// Search results and teasers: February 25, 2016
if ($vars['teaser'] || $vars['view_mode'] == 'search_result') {
$vars['submitted'] = t("%datetime", array('%datetime' => format_date($vars['node']->created, 'luggage_blog_teaser')));
} else {
$vars['submitted'] = t("%datetime", array('%datetime' => format_date($vars['node']->created, 'luggage_blog')));
}
}
}
function luggage_blog_views_pre_render(&$view) {
if ($view->name == 'blog' && $view->current_display == 'page') {
drupal_add_css(drupal_get_path('module', 'luggage_blog') . '/css/blog_blog.css');
} else if ($view->name == 'blog' && $view->current_display == 'person_blog_page' && isset($view->build_info['substitutions']['%1'])) {
$view->set_title($view->build_info['substitutions']['%1']);
drupal_add_css(drupal_get_path('module', 'luggage_blog') . '/css/luggage_blog_person.css');
} else if ($view->name == 'blog' && $view->current_display == 'blog_author_list_attachment') {
drupal_add_css(drupal_get_path('module', 'luggage_blog') . '/css/luggage_blog_author_list_attachment.css');
}
}
function luggage_blog_views_query_alter(&$view, &$query) {
if ($view->name == 'blog' && ($view->current_display == 'block_2' || $view->current_display == 'page_1')) {
$query->distinct = TRUE;
// $query->add_field('taxonomy_term_data', 'nid')
}
}
/**
* Implements hook_field_formatter_info_alter().
*/
function luggage_blog_field_formatter_info_alter(&$info) {
// Take over views_node_author format for a bit to change some things for blog.
// http://drupal.stackexchange.com/questions/58168/hook-into-other-modules-field-formatter
$info['views_node_author']['module'] = 'luggage_blog';
}
/**
* Implements hook_field_formatter_view().
*/
function luggage_blog_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
// Override the date format for blog author display.
// Bring in the luggage_aliases field formatter to get things set up.
$element = luggage_aliases_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display);
// Alter date format for luggage blog.
if ($entity->type == 'lug_blog' && $display['type'] == 'views_node_author') {
foreach ($items as $delta => $item) {
$element[$delta]['#created'] = format_date($entity->created, 'luggage_blog');
}
}
return $element;
}