You are here

function hook_themekey_properties in ThemeKey 7.3

Same name and namespace in other branches
  1. 7 docs/themekey.api.php \hook_themekey_properties()
  2. 7.2 docs/themekey.api.php \hook_themekey_properties()

By Implementing hook_themekey_properties() it's possible to add new properties to ThemeKey.

Two assign a value to a property during a page request you have three possibilities: 1. Provide a mapping function from one property to another and tell ThemeKey about it using this hook. 2. Implement hook_themekey_global(). 3. Implement hook_themekey_paths().

There's an example implementation of this hook,

Return value

An array of ThemeKey properties and mapping functions: array of ThemeKey property attributes: key: namespace:property value: array( description => Readable name of property (required) validator => Callback function to validate a rule starting with that property (optional) TODO: describe validator arguments and return value file => File that provides the validator function (optional) path => Alternative path relative to dupal's doc root to load the file (optional) static => true/false, static properties don't occur in properties drop down and have fixed operator and value (optional) page cache => Level of page caching support:

Default is THEMEKEY_PAGECACHE_UNSUPPORTED (optional) ) array of mapping functions key: none (indexed) value: array( src => Source property path (required) dst => Destination property path (required) callback => Mapping callback (required) file => File that provides the callback function (optional) path => Alternative path relative to dupal's doc root to load the file (optional) )

See also

themekey_example_themekey_properties()

23 functions implement hook_themekey_properties()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

themekey_blog_themekey_properties in modules/themekey.blog.inc
Implements hook_themekey_properties().
themekey_book_themekey_properties in modules/themekey.book.inc
Implements hook_themekey_properties().
themekey_browscap_themekey_properties in modules/themekey.browscap.inc
Implements hook_themekey_properties().
themekey_comment_themekey_properties in modules/themekey.comment.inc
Implements hook_themekey_properties().
themekey_compat_themekey_properties in ./themekey_compat.module
Implements hook_themekey_properties().

... See full list

2 invocations of hook_themekey_properties()
themekey_load_function in ./themekey_base.inc
Magic loading of validation and callback functions.
themekey_rebuild in ./themekey_build.inc
Rebuilds all ThemeKey-related Drupal variables by calling the hooks:

File

docs/themekey.api.php, line 50
ThemeKey API documentation

Code

function hook_themekey_properties() {

  // Attributes of properties
  $attributes = array();
  $attributes['example:number_one'] = array(
    'description' => t('Example: always returns "1"'),
    'validator' => 'themekey_example_validator_number_one',
    'file' => 'themekey_example_validators.inc',
    'page cache' => THEMEKEY_PAGECACHE_SUPPORTED,
  );
  $attributes['example:global_one'] = array(
    'description' => t('Example: always returns "1"'),
    'validator' => 'themekey_example_validator_number_one',
    'file' => 'themekey_example_validators.inc',
    'page cache' => THEMEKEY_PAGECACHE_SUPPORTED,
  );
  $attributes['example:path_number'] = array(
    'description' => t('Example: always returns "1"'),
    'validator' => 'themekey_validator_ctype_digit',
    'page cache' => THEMEKEY_PAGECACHE_SUPPORTED,
  );

  // Mapping functions
  $maps = array();
  $maps[] = array(
    'src' => 'system:dummy',
    'dst' => 'example:number_one',
    'callback' => 'themekey_example_dummy2number_one',
    'file' => 'themekey_example_mappers.inc',
  );
  return array(
    'attributes' => $attributes,
    'maps' => $maps,
  );
}