Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a custom logo and I have tried to get his path in this way theme_get_setting('logo_path'), but no expected result.

I am using the code in a custom block, in input PHP.

share|improve this question
2  
Where are you using this code? Have you tried theme_get_setting('logo_path', 'THEME_NAME'), replacing THEME_NAME with the name of your theme? –  marcvangend Mar 21 '11 at 13:21

2 Answers 2

up vote 3 down vote accepted

logo_path seems to only be set if you override the theme's default logo via its theme settings. To get the default logo, use theme_get_setting('logo').

share|improve this answer
    
But why the result of theme_get_setting('logo') is empty string ? I have set my custom logo in /admin/appearance/setting –  Ek Kosmos Mar 21 '11 at 13:53
    
Why when Logo is deactivate from theme TOGGLE DISPLAY - Enable or disable the display of certain page elements. the theme_get_setting('logo') has no results. Why ? –  Ek Kosmos Mar 21 '11 at 14:28
global $base_url;
drupal_theme_initialize();

if (!$logo = theme_get_setting('logo_path')) {
    $logo = theme_get_setting('logo');
}

if (!empty($logo)) {
  // [1]
  // Remove the base URL from the result returned by theme_get_setting('logo').
  // If you don't need the relative path, you can remove this code.
  if (strpos($logo, $base_url) === 0) {
    $logo = drupal_substr($logo, drupal_strlen($base_url));
  }
  // [1]
  // …
}

The call to drupal_theme_initialize() is not strictly necessary, and it doesn't do anything if the global variable $theme is already initialized.
The code is removing the base URL because the value reported from theme_get_setting('logo') is an absolute path; if you don't need a relative path to access the file, then the part between // [1] can be removed.

When the logo has been disabled in the theme settings, theme_get_setting('logo') doesn't return anything.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.