Skip to main content
added 9 characters in body
Source Link
Tyler Durden
  • 2.3k
  • 2
  • 27
  • 44

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module'module-template',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module-template',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

[Edit removed during grace period]
Source Link
Tyler Durden
  • 2.3k
  • 2
  • 27
  • 44
Added code
Source Link
Tyler Durden
  • 2.3k
  • 2
  • 27
  • 44

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message (maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this? How can I call this template from my hook_init?

Thanks in advance.

Source Link
Tyler Durden
  • 2.3k
  • 2
  • 27
  • 44
Loading