function template_preprocess_toc_tree in TOC API 8
Prepares variables for table of contents tree.
Default template: toc-tree.html.twig.
Parameters
array $variables: An associative array containing the following keys:
- toc: A TOC (table of contents) object.
- attributes: Attributes to be added to back to top link.
File
- ./
toc_api.module, line 113 - Converts header tags into a hierarchical table of contents.
Code
function template_preprocess_toc_tree(&$variables) {
/** @var \Drupal\toc_api\TocInterface $toc */
$toc = $variables['toc'];
$variables['tree'] = $toc
->getTree();
$variables['options'] = $toc
->getOptions();
$variables['attributes'] = new Attribute($variables['attributes']);
$variables['#attached']['library'][] = 'toc_api/toc.tree';
}