I've got a huge problem with my template preview. For all of my post (page, article and so on), I have not the good region in my page.
My theme is extended Classy.
If I go to see the page (not from the preview), I have the good page. But if I want to see the preview of this page, I've got some missing region (I guess this is a region).
See my page--post-type.html.twig
{% include '@theme/layout/header.html.twig' %}
{% include '@theme/includes/page-head.html.twig' %}
{% include '@theme/includes/page-breadcrumb.html.twig' %}
{% include '@theme/includes/page-entry.html.twig' %}
<section id="page-content">
<div class="container">
<div class="row"> {{ some displayed data }}
</div></div></section>
{% include '@theme/layout/footer.html.twig' %}
My included files a working (for both preview and view), but the preview isn't in this page is guess.
The last included block is this for the preview :
BEGIN OUTPUT from 'themes/theme/templates/block/block.html.twig'
And for some reason, after I have this :
BEGIN OUTPUT from 'core/themes/classy/templates/content/node.html.twig'
if it helps, my .theme file :
/**
* Implements hook_theme_suggestions_page_alter().
*/
function theme_theme_suggestions_page_alter(&$suggestions, $variables) {
// $node = \Drupal::routeMatch()->getParameter('node');
if ($node = \Drupal::routeMatch()->getParameter('node_preview')){
$node = \Drupal::routeMatch()->getParameter('node_preview');
// if ($node instanceof \Drupal\node\NodeInterface) {
// $suggestions[] = 'page__' . $node->bundle() . '_preview';
// $suggestions[] = 'page__node_' . $node->bundle() . '_preview';
// }
} else {
$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
$suggestions[] = 'page__' . $node->bundle();
$suggestions[] = 'page__node_' . $node->bundle();
}
}
// dump($suggestions);
}
And I have also this function alstef_preprocess_node() which I took from this : Place block region in node template
I've been stuck for hours, any help you be appreciated.
PS : I'm working on drupal 8 with a custom Theme (here called 'theme').
EDIT : I've just made a dump of my node, and the node is null is i'm on my page--post-type.html.twig or page--post-type-preview.html.twig with the preview (change thanks to suggestions)