Drupal 7 创建整页自定义模块

Drupal 7 Creating Full Page Custom Module

我想创建一个完整的页面,自定义模块。通过这个,我的意思是一个没有包装到主要 Drupal 站点中的模块。这是我的代码:

myapp.module:

function myapp_menu() 
{
 $result = array();
 $result['myapp/home'] = array(
  'title' => 'My App Title', // Title of our page
  'description'=> 'My App Web Site', // Description of our page
  'page callback' => 'myapp_function', 
  'access arguments' => array('access content'), // permission to access this page
  'type' => MENU_NORMAL_ITEM, // type of menu item
 );

 return $result;
}

function myapp_function(){      
  return theme('my_custom_template');
}       

function myapp_theme(){
  return array(
    'my_custom_template' => array(          
      'template' => 'myapp-page',
    ),
  );
}

我的应用-page.tpl.php

Hello World

问题是,当页面显示时,它仍然保留在 Drupal Sites 主主题中。我想让这个页面成为它自己的整页站点。谁能帮忙做这件事?

谢谢

你可以这样破解:

function myapp_function(){      
  print theme('my_custom_template');
  exit;
} 

您也可以使用 https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_theme/7.x

中列出的声明选项

Parameters

array $existing: An array of existing implementations that may be used for override purposes. This is primarily useful for themes that may wish to examine existing implementations to extract data (such as arguments) so that it may properly register its own, higher priority implementations.

$type: Whether a theme, module, etc. is being processed. This is primarily useful so that themes tell if they are the actual theme being called or a parent theme. May be one of:

'module': A module is being checked for theme implementations. 'base_theme_engine': A theme engine is being checked for a theme that is a parent of the actual theme being used. 'theme_engine': A theme engine is being checked for the actual theme being used. 'base_theme': A base theme is being checked for theme implementations. 'theme': The actual theme in use is being checked. $theme: The actual name of theme, module, etc. that is being being processed.

$path: The directory path of the theme or module, so that it doesn't need to be looked up.