1

I implemented a HOOK_module_theme_suggestions_node_alter to add a custom twig template. Now below is my code

function gf_theme_module_theme_suggestions_node_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'node--products-template--simple';
  
}

Now it does appear in the inspector but the page does not use the custom twig file I added eventhough the file exist. Any idea?

Below are the screenshot

enter image description here

enter image description here

I already cleared my cache but still no luck. It's still loading the node.html.twig eventhough the node--products-template--simple.html.twig exist. The file exist in the same folder as the node.html.twig file

apaderno
  • 28,547
  • 16
  • 75
  • 90
MadzQuestioning
  • 3,341
  • 8
  • 45
  • 76
  • Not sure if it's a typo or the cause of the issue, but the hook name is _HOOK_theme_suggestions_node_alter_ (not _HOOK_module_theme_suggestions_node_alter_). – EricLavault Feb 23 '22 at 12:38

1 Answers1

1

Use underscores instead of hyphens in suggestions:

$suggestions[] = 'node__products_template__simple';
Kien Nguyen
  • 2,616
  • 2
  • 7
  • 24