You are here

function themekey_example_themekey_properties in ThemeKey 7.2

Same name and namespace in other branches
  1. 7.3 themekey_example/themekey_example.module \themekey_example_themekey_properties()
  2. 7 themekey_example/themekey_example.module \themekey_example_themekey_properties()

Implements hook_themekey_properties().

A mapping function declared here only runs if really required during a page request.

So complicated, time and memory consuming properties should be added to ThemeKey by implementing hook_themekey_properties().

File

themekey_example/themekey_example.module, line 22
ThemeKey Example demonstrates the usage of ThemeKeys API to add more properties to ThemeKey.

Code

function themekey_example_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,
  );
}