Dru Documentation

Go to front page

developer/hooks/core.php, string 1802 Versions 6 hook_theme ($existing, $type, $theme, $path) "Translation" the Pre-image Registers темизации the unit or a subject. Units and the subjects realising these хук, return the array of associative arrays. The key of each of under-arrays is an interior name хука, and itself under-file contains the information about хуке. Everyone under-array can contain following items: * ' arguments': (a mandatory key) the Array of parametres given хука темизации. He allows a subject stratum to use files of templates correctly. Each parametre is described as steam a key-value where a key is the parametre name, and by value - value of this parametre on default (it will be used if this parametre is not transferred functions theme ()). The order of parametres in exposition should coincide with order in which they will be transmitted in theme (). * ' file ': the Filename in which there is an implementation given хука темизации. This file will be included before subject mapping, that подгрузить necessary function for a subject stratum; thanks to it functions темизации can be carried out in a separate file and подгружать only if necessary. * ' path ': the Path to an include-file, указаному in a key ' file '. In most cases ' path ' it is possible not to specify, and the file will be taken from one directory with the unit/theme. But if the file is in other place, it is necessary to specify it. The path should be relative, since root directory Drupala. * ' template ': If it is set, this key specifies that given темизация is realised by means of the template, and also sets a name of the template (without.tpl.php extension). The extension will add a standard scroll box that Drupala (PHPTemplate). If the parametre ' path ' the template it will be loaded from the directory set by this parametre is set also. * ' function ': If this key is set, it will be used as a function name, realising given хук темизации. If any of keys ' file ' and ' function ' it is considered is not set that implementation хука is in function with a name by default. For the unit which has registered хук темизации ' node ', function by default is named ' theme_node '. For a subject chameleon, registered хук ' node ', function is named ' chameleon_node '. * ' pattern ': A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme. For example, to allow forums to be themed individually, the pattern might be: ' forum __ '. Then, when the forum is themed, call: theme (array (' forum __ '. $tid, ' forum '), $forum). * ' preprocess functions': the Array of functions for preliminary handling of parametres хука. Ordinarily this will not be used; it's automatically filled in. By default, for a module this will be filled in as template_preprocess_HOOK. For a theme this will be filled in as phptemplate_preprocess and phptemplate_preprocess_HOOK as well as themename_preprocess and themename_preprocess_HOOK. * ' override preprocess functions': Set to TRUE when a theme does NOT want the standard preprocess functions to run. This can be used to give a theme FULL control over how variables are set. For example, if a theme wants total control over how certain variables in the page.tpl.php are set, this can be set to true. Please keep in mind that when this is used by a theme, that theme becomes responsible for making sure necessary variables are set. * ' type ': (automatically derived) Where the theme hook is defined: ' module ', ' theme_engine ', or ' theme '. * ' theme path ': (automatically derived) The directory path of the theme or module, so that it does not need to be looked up. * ' theme paths': (automatically derived) An array of template suggestions where.tpl.php files related to this theme hook may be found. The following parametres are all optional. Parametres $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 What ' type ' 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 which 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 that is being being checked (mostly only useful for theme engine). $path The directory path of the theme or module, so that it does not need to be looked up. Returned value The array with keys хуков subjects. Register a module (or theme's) theme implementations. Modules and themes implementing this return an array of arrays. The key to each sub-array is the internal name of the hook, and the array contains info about the hook. Each array may contain the following items: * arguments: (required) An array of arguments that this theme hook uses. This value allows the theme layer to properly utilise templates. The array keys represent the name of the variable, and the value will be used as the default value if not specified to the theme () function. These arguments must be in the same order that they will be given to the theme () function. * file: The file the implementation resides in. This file will be included prior to the theme being rendered, to make sure that the function or preprocess function (as needed) is actually loaded; this makes it possible to split theme functions out into separate files quite easily. * path: Override the path of the file to be used. Ordinarily the module or theme path will be used, but if the file will not be in the default path, include it here. This path should be relative to the Drupal root directory. * template: If specified, this theme implementation is a template, and this is the template file without an extension . Do not put.tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If ' path ', above, is specified, the template should also be in this path. * function: If specified, this will be the function name to invoke for this implementation. If neither file nor function is specified, a default function name will be assumed. For example, if a module registers the ' node ' theme hook, ' theme_node ' will be assigned to its function. If the chameleon theme registers the node hook, it will be assigned ' chameleon_node ' as its function. * pattern: A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme. For example, to allow forums to be themed individually, the pattern might be: ' forum __ '. Then, when the forum is themed, call: theme (array (' forum __ '. $tid, ' forum '), $forum) . * preprocess functions: A list of functions used to preprocess this data. Ordinarily this will not be used; it's automatically filled in. By default, for a module this will be filled in as template_preprocess_HOOK. For a theme this will be filled in as phptemplate_preprocess and phptemplate_preprocess_HOOK as well as themename_preprocess and themename_preprocess_HOOK. * override preprocess functions: Set to TRUE when a theme does NOT want the standard preprocess functions to run. This can be used to give a theme FULL control over how variables are set. For example, if a theme wants total control over how certain variables in the page.tpl.php are set, this can be set to true. Please keep in mind that when this is used by a theme, that theme becomes responsible for making sure necessary variables are set. * type: (automatically derived) Where the theme hook is defined: ' module ', ' theme_engine ', or ' theme '. * theme path: (automatically derived) The directory path of the theme or module, so that it does not need to be looked up. * theme paths: (automatically derived) An array of template suggestions where.tpl.php files related to this theme hook may be found. The following parametres are all optional. Parameters $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 What ' type ' 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 which 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 that is being being checked (mostly only useful for theme engine). $path The directory path of the theme or module, so that it does not need to be looked up. Return value A keyed array of theme hooks. The linked subjects Хуки Allows units to co-operate with kernel Drupal. ? 1 function calls hook_theme ()