forked from misd-service-development/drupal-feature-teasers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cambridge_teasers.module
55 lines (51 loc) · 1.75 KB
/
cambridge_teasers.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
<?php
/**
* @file
* Code for the Teasers feature.
*/
/**
* Implements hook_entity_info_alter().
*/
function cambridge_teasers_entity_info_alter(&$entity_info) {
if (isset($entity_info['node']['view modes']['teaser'])) {
$entity_info['node']['view modes']['teaser']['label'] = 'Horizontal Teaser';
}
$entity_info['node']['view modes'] += array(
'vertical_teaser' => array(
'label' => t('Vertical Teaser'),
'custom settings' => TRUE,
),
'sidebar_teaser' => array(
'label' => t('Sidebar Teaser'),
'custom settings' => TRUE,
),
);
}
/**
* Implements hook_theme_registry_alter().
*/
function cambridge_teasers_theme_registry_alter(&$theme_registry) {
$theme_registry['node____teaser'] = array(
'template' => drupal_get_path('module', 'cambridge_teasers') . '/templates/node----teaser',
'type' => 'module',
);
$theme_registry['node____vertical_teaser'] = array(
'template' => drupal_get_path('module', 'cambridge_teasers') . '/templates/node----vertical-teaser',
'type' => 'module',
);
$theme_registry['node____sidebar_teaser'] = array(
'template' => drupal_get_path('module', 'cambridge_teasers') . '/templates/node----sidebar-teaser',
'type' => 'module',
);
}
/**
* Implements template_preprocess_node().
*/
function cambridge_teasers_preprocess_node(&$vars) {
if (in_array($vars['view_mode'], array('teaser', 'vertical_teaser', 'sidebar_teaser'))) {
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
$vars['theme_hook_suggestions'][] = 'node__' . $vars['nid'] . '__' . $vars['view_mode'];
$vars['theme_hook_suggestions'][] = 'node____' . $vars['view_mode'];
$vars['date'] = format_date($vars['node']->created, 'custom', 'j F Y');
}
}