-
Notifications
You must be signed in to change notification settings - Fork 0
/
tribute_cards.module
96 lines (85 loc) · 2.66 KB
/
tribute_cards.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @file
* Contains tribute_cards.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function tribute_cards_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the tribute_cards module.
case 'help.page.tribute_cards':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Allows you to create and manage ecards and paper cards and send them to users.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
// function tribute_cards_theme() {
// return [
// 'tribute_cards' => [
// 'render element' => 'children',
// ],
// ];
// }
/**
* Implements hook_theme().
*/
function tribute_cards_theme() {
$theme = [];
$theme['card_entity'] = [
'render element' => 'elements',
'file' => 'card_entity.page.inc',
'template' => 'card_entity',
];
$theme['card_entity_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'card_entity.page.inc',
];
$theme['ecard_item'] = [
'render element' => 'elements',
'file' => 'ecard_item.page.inc',
'template' => 'ecard_item',
];
$theme['ecard_item_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'ecard_item.page.inc',
];
return $theme;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function tribute_cards_theme_suggestions_card_entity(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#card_entity'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'card_entity__' . $sanitized_view_mode;
$suggestions[] = 'card_entity__' . $entity->bundle();
$suggestions[] = 'card_entity__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'card_entity__' . $entity->id();
$suggestions[] = 'card_entity__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function tribute_cards_theme_suggestions_ecard_item(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#ecard_item'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'ecard_item__' . $sanitized_view_mode;
$suggestions[] = 'ecard_item__' . $entity->bundle();
$suggestions[] = 'ecard_item__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'ecard_item__' . $entity->id();
$suggestions[] = 'ecard_item__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}