forked from TCCL/field_table_of_contents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfield_table_of_contents.module
62 lines (52 loc) · 1.14 KB
/
field_table_of_contents.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
<?php
/**
* field_table_of_contents.module
*
* field_table_of_contents
*/
/**
* Implements hook_theme().
*/
function field_table_of_contents_theme($existing,$type,$theme,$path) {
return [
'field_table_of_contents_field' => [
'variables' => [
'title' => '',
'contents' => [],
],
],
'field_table_of_contents_inject' => [
'variables' => [
'anchor' => '',
'field' => '',
],
],
];
}
/**
* Implements hook_preprocess_node().
*/
function field_table_of_contents_preprocess_node(&$variables) {
$generator = Drupal::service('field_table_of_contents.generator');
$node = $variables['node'];
$toc = $generator->lookup($node);
if ($toc) {
$toc->preprocessEntity($variables,$node);
}
}
/**
* Implements hook_preprocess_paragraph().
*/
function field_table_of_contents_preprocess_paragraph(&$variables) {
$generator = Drupal::service('field_table_of_contents.generator');
$paragraph = $variables['paragraph'];
$toc = $generator->lookup($paragraph);
if ($toc) {
$toc->preprocessEntity($variables,$paragraph);
}
}
/**
* Local Variables:
* mode:php
* End:
*/