{# link is in html.html.twig #} -
+
{{ page.content }}
{# /.layout-content #} diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region--header.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region--header.html.twig index b513d75ee..2b361156c 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region--header.html.twig +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region--header.html.twig @@ -16,7 +16,7 @@ #} {% if content %} -
+
diff --git a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region.html.twig b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region.html.twig index 8fede7b6d..de6c43457 100644 --- a/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region.html.twig +++ b/web/profiles/custom/os2loop/themes/os2loop_theme/templates/layout/region.html.twig @@ -15,7 +15,7 @@ */ #} {% if content %} - + {{ content }}
{% endif %} From 529732d3ffbfe06186350ac075067d94f612ab1b Mon Sep 17 00:00:00 2001 From: martinyde Date: Fri, 15 Oct 2021 08:57:58 +0200 Subject: [PATCH 7/7] LOOP-1079: Changed stuff after code review --- .../os2loop_toc_block/src/Helper/Helper.php | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/web/profiles/custom/os2loop/modules/os2loop_toc_block/src/Helper/Helper.php b/web/profiles/custom/os2loop/modules/os2loop_toc_block/src/Helper/Helper.php index 5929def30..eec9b2080 100644 --- a/web/profiles/custom/os2loop/modules/os2loop_toc_block/src/Helper/Helper.php +++ b/web/profiles/custom/os2loop/modules/os2loop_toc_block/src/Helper/Helper.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Field\EntityReferenceFieldItemList; use Drupal\Core\Render\RendererInterface; use Drupal\node\NodeInterface; use Drupal\toc_api\TocBuilder; @@ -62,7 +63,7 @@ public function __construct(TocManagerInterface $tocManager, TocBuilder $tocBuil } /** - * Implements hook_ckeditor_css_alter(). + * Implements hook_node_view(). * * Adds Ids to headers related to table of contents. * @@ -83,22 +84,25 @@ public function nodeView(array &$build, NodeInterface $node, EntityViewDisplayIn $lock = &drupal_static(__FUNCTION__, FALSE); if (!$lock) { $lock = TRUE; - if ($view_mode == 'full') { + if ('full' === $view_mode) { $hasToc = FALSE; - $paragraphs_content = $node->get('os2loop_documents_document_conte')->getValue(); - $paragraph_storage = $this->entityTypeManager->getStorage('paragraph'); - foreach ($paragraphs_content as $paragraph) { - if ('table_of_contents' == $paragraph_storage->load($paragraph['target_id'])->bundle()) { - $hasToc = TRUE; - } - } - if ($hasToc) { - $node_html = (string) $this->renderer->render($build); + if ($node->hasField('os2loop_documents_document_conte')) { + $paragraphsContent = $node->get('os2loop_documents_document_conte'); + assert($paragraphsContent instanceof EntityReferenceFieldItemList); + $paragraphs = $paragraphsContent->referencedEntities(); - $toc = $this->createToc($node_html); - - if ($toc->isVisible()) { - $build['#markup'] = $this->tocBuilder->buildContent($toc)['#markup']; + foreach ($paragraphs as $paragraph) { + if ('table_of_contents' == $paragraph->bundle()) { + $hasToc = TRUE; + break; + } + } + if ($hasToc) { + $node_html = (string) $this->renderer->render($build); + $toc = $this->createToc($node_html); + if ($toc->isVisible()) { + $build['#markup'] = $this->tocBuilder->buildContent($toc)['#markup']; + } } } }