I want the logo in my header (logo.png) to link to an outside URL instead of the home page. I just started using Firebug but can't decipher what file I need to alter to make this happen. Where do I change the attributes for that tag?

Comments

StephenRobinson’s picture

go to your sites themes/themename/ folder and edit the page.tpl.php?

      <?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>

replace with:

 <?php $mynewurl='http://someothersite/';
 if ($logo) { ?><a href="<?php print $mynewurl ?>" title="<?php print t($mynewurl) ?>"><img src="<?php print $logo ?>" alt="<?php print t($mynewurl ?>" /></a><?php } ?>
jimdemon’s picture

My themes folder is sites/all/themes/pixture_reloaded

the page.tpl.php in there doesn't have the code you indicate. This is all I have for the logo in page.tpl.php

        <?php if ($site_logo): ?>
          <div id="logo"><?php print $site_logo; ?></div>
        <?php endif; ?>"

So what else could be generating that code?

Jeff Burnz’s picture

Its in template.php - this theme preprocesses the normal ugly code used in most other themes.

Around line 108 in template.php find...

  if (!empty($vars['logo'])) {
    $vars['site_logo'] = '<a href="'. $vars['front_page'] .'" title="'. t('Home page') .'" rel="home"><img src="'. $vars['logo'] .'" alt="'. $vars['site_name'] .' '. t('logo') .'" /></a>';
  }

and change it to...

  if (!empty($vars['logo'])) {
    $vars['site_logo'] = '<a href="http://someothersite.com" title="'. t('Some other site') .'"><img src="'. $vars['logo'] .'" alt="'. $vars['site_name'] .' '. t('logo') .'" /></a>';
  }
jimdemon’s picture

Status: Active » Closed (fixed)

Snap! Like a charm. Thanks y'all.

ebertus’s picture

Assigned: Unassigned » ebertus
Status: Closed (fixed) » Active

Sorry, must reopen this topic!

Being relative new to drupal and php (was programming turbo pascal nearly 20 years ago), I still figured out what Jeff Burnz ist posting here, before I found this thread. But it does not work on my installation.

I use an own logo, not the standard one from drupal an my drupal version is 6.19 with german language. The theme "picture-reloaded" is great, exactly what I need, after having "garland" for the first time of my experience with drupal. And it will be even greater, when on click on the logo will lead to an specific url; external or to an defined page in my project.

Jeff Burnz’s picture

@#5 see #3, this has already been answered in detail. If its not working then you have 1) made a mistake or 2) changing something else as well that I don't know about.

ebertus’s picture

Thanks for your prompt answer, I did it again. No mistake, no changing, and "now" it works - but only, when the user has signed in!!! I don't tried this during my first quick test.

OK, better the before but my site ist mostly readable without an account and the need to log in. So I think, there must be another point of reference, because something happens behind the scenes, when the logo ist clicked without being logged on.

Thank you for your patience.

atero’s picture

atero’s picture

Hi,
I am also new with Drupal since some months.

The problem is:
I can´t find a possibility to link to an "outside url", if an user klicks on the Logo.

Although I read since days and nights about this problem, I read everywhere ..., but I could not solve that problem.

Might it be, that the cause of my current problem is, that there is a big
difference between the version of Pixture Reloaded to which the old question from above (from 2010) referres to, to my version of Pixture Reloaded?

I use:
Pixture Reloaded 7.x-3.0-rc1 (default theme) - enabled,
and
AT Admin, AT Core, AT Subtheme 7.x-3.1 - installed
and
drupal7,15

There seems to be a difference between the code of the old version an the code of my version.

I am not familiar with php, learned 20 years ago turbo pascal and und understand very basic of css, only.
I really can´t find any solution and have worked at that Problem days and nights.
Is there anybody out there who can help me?
Am I allone with that problem???

My question is:
I can´t find a possibility to link to an "outside url", if the user klicks on the Logo.

In my pixture_reloaded\templates\page.tpl.php of that new version 7.x-3.0-rc1
does not exist a line as mentioned in the answeres before.


<?php if ($site_logo || $site_name || $site_slogan): ?>
          <!-- start: Branding -->
          <div id="branding" class="branding-elements clearfix">

            <?php if ($site_logo): ?>
            	<div id="logo">
                <?php print $site_logo; ?>
              </div>
            <?php endif; ?>

            <?php if ($site_name || $site_slogan): ?>
              <!-- start: Site name and Slogan hgroup -->
              <hgroup id="name-and-slogan"<?php print $hgroup_attributes; ?>>

                <?php if ($site_name): ?>
                  <h1 id="site-name"<?php print $site_name_attributes; ?>><?php print $site_name; ?></h1>
                <?php endif; ?>

                <?php if ($site_slogan): ?>
                  <h2 id="site-slogan"<?php print $site_slogan_attributes; ?>><?php print $site_slogan; ?></h2>
                <?php endif; ?>

              </hgroup><!-- /end #name-and-slogan -->
            <?php endif; ?>

          </div><!-- /end #branding -->
        <?php endif; ?>

There is no href with the possibility to link to an "outside url".

PLEASE, PLEASE can somebody give me a hint.

It would be very pleased

In advance a very GREAT Thanks

atero

Jeff Burnz’s picture

Its really this easy, in template.php and replace http://drupal.org with your URL, clear the cache, naturally:

function pixture_reloaded_preprocess_page(&$vars) {
  $vars['site_logo'] = $vars['logo_img'] ? l($vars['logo_img'], 'http://drupal.org', array('attributes' => array('title' => t('Home page')), 'html' => TRUE)) : '';
}
luiggi’s picture

Issue summary: View changes

Dear all,
Some suggestion to solve this issue in Drupal 8.x?.

Luis M.

imingridm’s picture

I read several things about but I can not find this path "page.tpl.php", I opened other "php" extensions but I did not find any lines referring to:
"<? Php if ($ logo):?>
     print $front_page; "title ="
"rel =" home "id =" logo "

I'm using the Bootstrap Sub-Theme.

scarer’s picture

Any updates on the Drupal 8 workaround for a Bootstrap sub-theme?