欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal 自定义主题

shiping1 的头像

function hook_custom_theme

7 system.api.phphook_custom_theme()
8 system.api.phphook_custom_theme()

Return the machine-readable name of the theme to use for the current page.

This hook can be used to dynamically set the theme for the current page request. It should be used by modules which need to override the theme based on dynamic conditions (for example, a module which allows the theme to be set based on the current user's role). The return value of this hook will be used on all pages except those which have a valid per-page or per-section theme set via a theme callback function in hook_menu(); the themes on those pages can only be overridden using hook_menu_alter().

Note that returning different themes for the same path may not work with page caching. This is most likely to be a problem if an anonymous user on a given path could have different themes returned under different conditions.

Since only one theme can be used at a time, the last (i.e., highest weighted) module which returns a valid theme name from this hook will prevail.

Return value

The machine-readable name of the theme that should be used for the current page request. The value returned from this function will only have an effect if it corresponds to a currently-active theme on the site. Do not return a value if you do not wish to set a custom theme.

Related topics

4 functions implement hook_custom_theme()
1 invocation of hook_custom_theme()

File

 

modules/system/system.api.php, line 2313
Hooks provided by Drupal core and the System module.

Code

function hook_custom_theme() {
  // Allow the user to request a particular theme via a query parameter.
  if (isset($_GET['theme'])) {
    return $_GET['theme'];
  }
}


来自 https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_custom_theme/7
普通分类: