Skip to main content
Commonmark migration
Source Link

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',
      'variables'=>array('test'=>NULL),
      'render element' => 'children',
    ],

      'page2' => [
          'template' => 'page2',       
          'render element' => 'form',
      ],
  
  ];
}

And after, in your controller or your form :

return $build +  [
  '#theme'=>'page1',
  '#test'=>"its content for my variable inside my template",
];

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',
      'variables'=>array('test'=>NULL),
      'render element' => 'children',
    ],

      'page2' => [
          'template' => 'page2',       
          'render element' => 'form',
      ],
  
  ];
}

And after, in your controller or your form :

return $build +  [
  '#theme'=>'page1',
  '#test'=>"its content for my variable inside my template",
];

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',
      'variables'=>array('test'=>NULL),
      'render element' => 'children',
    ],

      'page2' => [
          'template' => 'page2',       
          'render element' => 'form',
      ],
  
  ];
}

And after, in your controller or your form :

return $build +  [
  '#theme'=>'page1',
  '#test'=>"its content for my variable inside my template",
];
added 3 characters in body
Source Link
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',
      'variables'=>array('test'=>NULL),
      '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''#theme'=>'page1',
  '#test'=>"its content for my variable inside my template",
];

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",
];

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',
      'variables'=>array('test'=>NULL),
      'render element' => 'children',
    ],

      'page2' => [
          'template' => 'page2',       
          'render element' => 'form',
      ],
  
  ];
}

And after, in your controller or your form :

return $build +  [
  '#theme'=>'page1',
  '#test'=>"its content for my variable inside my template",
];
Source Link
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",
];