1

I'm working with a multisite Drupal 7 install with many sites. The site accepts both "www." and without via Apache. I'm developing a themes in /sites/all/themes which is used by many of these sites and I want something like this:

$apple_icon =  array(
    '#tag' => 'link',
    '#attributes' => array(
      'href' => '/' . path_to_site() . '/apple-touch-icon.png',
      'rel' => 'apple-touch-icon',
    ),
  );
  drupal_add_html_head($apple_icon, 'apple-touch-icon');

where path_to_site gives like /www/drupal7/sites/blah.com etc. depending on the site being used. I need this since each site will need a different icon.

I guess something like '/sites/' . $_SERVER['HTTP_HOST'] and then I can use symlink aliases for the "www." variant.

How can I do this properly?

1 Answer 1

1

You can use conf_path to get the path root to the current site - then append the rest of your path to that.

Returns the configuration path based on the site's hostname, port, and pathname.

e.g:

$apple_icon =  array(
  '#tag' => 'link',
  '#attributes' => array(
    'href' => base_path() . conf_path() . '/apple-touch-icon.png',
    'rel' => 'apple-touch-icon',
  ),
);
drupal_add_html_head($apple_icon, 'apple-touch-icon');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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