Skip to main content
1 of 3
Kevin
  • 2.6k
  • 5
  • 26
  • 42

You cannot specify region on your module, but you can custom your page or your block.

Regions are specify into main theme.

First, you need to create a folder on your module root directory :

myModule/templates

Inside, you ll put all your custom template.

For example :

page1.html.twig

page2.html.twig

Then you need to declare all your templates :

In myModule.module :

/**
 * Implements hook_theme().
 */
function myModule_theme() {
  return [
    'page1' => [
      'template' => 'test',
      'render element' => 'children',
    ],

      'page2' => [
          'template' => 'page2',
          'variables'=>array('test'=>NULL),
          'render element' => 'form',
      ],
  
  ];
}

And after, in your controller or your form :

return $build +  [
  '#theme'=>'page2',
  '#test'=>"its content for my variable inside my template",
];
Kevin
  • 2.6k
  • 5
  • 26
  • 42