diff --git a/logo_token/README.txt b/logo_token/README.txt new file mode 100644 index 0000000..e3c9234 --- /dev/null +++ b/logo_token/README.txt @@ -0,0 +1,4 @@ +1. Place module in sites/all/modules/ or sites/all/modules/custom +2. Enable module. +3. Use token: [site:logo]. +4. Disco dancing. \ No newline at end of file diff --git a/logo_token/logo_token.info b/logo_token/logo_token.info new file mode 100644 index 0000000..ce5ffaa --- /dev/null +++ b/logo_token/logo_token.info @@ -0,0 +1,5 @@ +name = Logo token +description = Adds a token for the site theme logo +core = 7.x +package = custom +files[] = logo_token.module diff --git a/logo_token/logo_token.module b/logo_token/logo_token.module new file mode 100644 index 0000000..cf8669e --- /dev/null +++ b/logo_token/logo_token.module @@ -0,0 +1,36 @@ + t('Logo'), + 'description' => t('Site logo'), + ); + return $info; +} + +/** + * Provide replacement values for placeholder tokens. + */ +function logo_token_tokens($type, $tokens, array $data = array(), array $options = array()) { + $replacements = array(); + foreach ($tokens as $name => $original) { + switch ($name) { + case 'logo': + // see: http://drupal.stackexchange.com/questions/1102/how-to-get-the-logo-path-in-drupal-7 + global $base_url; + drupal_theme_initialize(); + + if (!$logo = theme_get_setting('logo_path')) { + $logo = theme_get_setting('logo'); + $replacements[$original] = $logo; + } + + break; + } + } + + return $replacements; +}