Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
I am creating the header on my page using the busy theme. I actually got my header working but I want to have a one for the german (default) and the english page.
So I made these changes in the page.tpl.php:
<div id="logo-floater">
<?php if ($logo || $site_title): ?>
<div id="branding" class="clearfix">
<a href="<?php print $front_page ?>" title="<?php print $site_name_and_slogan ?>">
<?php if ($logo): ?>
<img src="<?php echo busy_header_image() ?>" alt="<?php print $site_name_and_slogan ?>" id="logo" />
<?php endif; ?>
<span class="site-title"><?php print $site_name ?></span>
</a>
</div>
<?php else: /* Use h1 when the content title is empty */ ?>
<h1 id="branding">
<a href="<?php print $front_page ?>" title="<?php print $site_name_and_slogan ?>">
<?php if ($logo): ?>
<img src="<?php echo busy_header_image() ?>" alt="<?php print $site_name_and_slogan ?>" id="logo" />
<?php endif; ?>
</a>
</h1>
<?php endif; ?>
</div>
And I added this code to the template.php:
function busy_header_image() {
global $language;
return path_to_theme() . '/images/header_' . $language->language . '.png';
}
It is working fine for me on the home page but all other sites just have the site name on it.
Can you please help me fix this problem?
Comments
Comment #1
stBorchertHi.
With
path_to_theme() . '/images/header_' . $language->language . '.png'
you are creating a relative path. On the homepage this will be example.com/sites/all/themes/busy/images/header_de.png (for example) but on a node-page it expands to example.com/node/123/sites/all/themes/busy/images/header_de.png.Try using url() to create the path:
hth,
Stefan
Comment #2
mpmarth CreditAttribution: mpmarth commentedHi,
thank you for the help. I changed my code with your version and it works fine on the german pages of the website. But the header is missing on every english page.
Something is not quite right. Is the language attribute out of the $language object 'en'?
Otherwise I can not see the problem with this code. It should be able to do this but it doesn't.
mpmarth