[support] theme preprocessing - path issue

Ursula Pieper dramamezzo at gmail.com
Sat Aug 25 00:57:30 UTC 2012


Never mind, found the problem. The drupal_get_path call is wrong. I am
using $GLOBALS['base_path'] now instead, and all is fine. Ursula

On Fri, Aug 24, 2012 at 5:50 PM, Ursula Pieper <dramamezzo at gmail.com> wrote:

> I am trying to add an additional logo to my D7 site.
> I added to the template.php the following:
>
> function mytheme_preprocess_page(&$variables, $hook) {
>   $theme_path = drupal_get_path('theme', variable_get('theme_default',
> NULL));
>   $variables['second_logo'] = $base_path . '/' . $theme_path .
> '/images/second_logo.png';
> }
>
> and on page.tpl.php, I use the variable $second_logo, which correctly goes
> to:
>
> http://example.com/drupal_site/sites/all/themes/mytheme/images/second_logo.png
>
> This works fine for the home page:
>
> http://example.com/*drupal_site*
> /sites/all/themes/mytheme/images/second_logo.png
>
> However, when I am looking at a content page:
> http://example.com/drupal_site/content/whateverpage
>
> The url for the second logo gets constructed as:
> http://example.com/drupal_site/*content*
> /sites/all/themes/mytheme/images/second_logo.png
>
> So, I add the base path to template.php:
>
> $base_path = drupal_get_path('theme', variable_get('base_path', NULL));
> $theme_path = drupal_get_path('theme', variable_get('theme_default',
> NULL));
> $variables['second_logo'] = $base_path . '/' . $theme_path .
> '/images/second_logo.png';
>
> base_path, according to http://api.drupal.org/api/drupal/globals/7 is
> supposed to bet the base of the Drupal installation, which in my case is
> http://example.com/drupal_site/
>
> However, the path for the second logo gets constructed as:
> http://example.com/sites/all/themes/mytheme/images/second_logo.png
>
> instead of
>
> http://example.com/*drupal_site*
> /sites/all/themes/mytheme/images/second_logo.png
>
>  D7.15, zen 7.15 sub-theme.
>
> What am I don't wrong?
>
> Thanks, Ursula
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120824/c78cb502/attachment-0001.html 


More information about the support mailing list