-
Notifications
You must be signed in to change notification settings - Fork 0
/
xm_drupal_manual.module
85 lines (74 loc) · 2.46 KB
/
xm_drupal_manual.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
<?php
/**
* Implements hook_theme().
*/
function xm_drupal_manual_theme($existing, $type, $theme, $path)
{
$book_export_html = $existing['book_export_html'];
$book_node_export_html = $existing['book_node_export_html'];
$paragraph = $existing['paragraph'];
$field__node__title__book = $existing['field__node__title'];
$book_export_html['template'] = 'book-export-html--manual';
unset($book_export_html['path']);
$book_node_export_html['template'] = 'book-node-export-html--manual';
unset($book_node_export_html['path']);
$paragraph['template'] = 'paragraph--manual';
unset($paragraph['path']);
$field__node__title__book['template'] = 'field--node--title--book';
unset($field__node__title__book['path']);
return [
'book_export_html__manual' => $book_export_html,
'book_node_export_html__manual' => $book_node_export_html,
'paragraph__manual' => $paragraph,
'field__node__title__book' => $field__node__title__book,
];
}
/**
* Implements hook_theme_suggestions_alter().
*/
function xm_drupal_manual_theme_suggestions_book_node_export_html_alter(array &$suggestions, array &$variables, $hook)
{
$suggestions[] = 'book_node_export_html__manual';
}
/**
* Implements hook_theme_suggestions_alter().
*/
function xm_drupal_manual_theme_suggestions_book_export_html_alter(array &$suggestions, array &$variables, $hook)
{
$suggestions[] = 'book_export_html__manual';
}
/**
* Implements hook_theme_suggestions_alter().
*/
function xm_drupal_manual_theme_suggestions_paragraph_alter(array &$suggestions, array &$variables, $hook)
{
if(str_contains(\Drupal::service('path.current')->getPath(), 'book')) {
$suggestions[] = 'paragraph__manual';
}
}
/**
* Implements hook_local_tasks_alter().
*/
function xm_drupal_manual_local_tasks_alter(&$local_tasks)
{
// remove outline tab (Gliederung) for all nodes
unset($local_tasks['entity.node.book_outline_form']);
}
/**
* Implements hook_form_alter().
*/
function xm_drupal_manual_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
// show book outline menu only in right tab
if (!in_array($form_id, ['node_book_edit_form','node_book_form'], true)) {
unset($form['book']);
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function xm_drupal_manual_preprocess_book_export_html(&$variables)
{
// path to module
$variables['path'] = \Drupal::service('extension.list.module')->getPath('xm_drupal_manual');
}