How to get the absolute path to the sites/all folder in drupal?

perpetual_dream picture perpetual_dream · Dec 3, 2011 · Viewed 15.2k times · Source

I want to display two different logos on my drupal site: one for the front page and one for the inner pages.

if (drupal_is_front_page()) { 
    $variables['logo']=drupal_get_path('theme', 'hanna') . '/images/logo.png';
  } 
   else {
    $variables['logo']=drupal_get_path('theme', 'hanna') . '/images/logo-inner.png';    
  }

This works just fine for the front page and any page which has websiteurl/page as URL; however, it doesn't work for the pages where the URL is similar to websiteurl/custompath/page.

I think the problem lies in the relativeness of the pages which have a custom URL path.

Do you have any idea?

Answer

Nebel54 picture Nebel54 · Dec 3, 2011

You can use the drupal global $base_url to get the absolute path of the installation and append the absolute path of your image to it.

See the Drupal Documentation to this topic.

You can also use base_path() to get the path.