File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,25 @@ function minimal_preprocess_node(&$variables) {
279
279
if(\Drupal::routeMatch()->getParameter('node')){
280
280
$node = \Drupal::routeMatch()->getParameter('node');
281
281
$ntype = $node->getType();
282
- if($ntype == 'blog_post'){
282
+ $table_of_contents_map = array(
283
+ 'article_chapitre' => 'block_3',
284
+ 'chapitre' => 'block_1',
285
+ 'livre' => 'block_2',
286
+ );
287
+ if (array_key_exists($ntype, $table_of_contents_map)) {
288
+ $args = [$node->nid->value];
289
+ $view = \Drupal\views\Views::getView('table_matieres_article_livre');
290
+ // @see https://drupal.stackexchange.com/a/259795
291
+ if (is_object($view)) {
292
+ $view->setArguments($args);
293
+ $view->setDisplay($table_of_contents_map[$ntype]);
294
+ $view->preExecute();
295
+ $view->execute();
296
+ $variables['table_of_contents'] = $view->buildRenderable(
297
+ $table_of_contents_map[$ntype], $args);
298
+ }
299
+ }
300
+ if($ntype == 'blog_post'){
283
301
//related posts start
284
302
//kint($node->field_category);
285
303
$tids = array();
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ set classes = [
138
138
</div >
139
139
<aside class =" sidebar mi-menu fixed-area one-page-menu" data-topscroll =" 80" style =" width: 263px;" >
140
140
<nav class =" sidebar-nav" >
141
+ {{ table_of_contents }}
141
142
TABLE DES MATIÈRES<br />
142
143
À VENIR
143
144
</nav >
You can’t perform that action at this time.
0 commit comments