I want to change the powered by image to one of the other available images in the misc directory. I the powered by block doesn't have a why to do this, so I'm assuming it's hard coded somewhere. I would like to use the 132x42 images instead. I know how to create a block and display the image using the Body: editor. Is this something possible with this block?

Comments

vm’s picture

The image can't be altered by editing the block? I believe there is a drop down in the block edit screen?

scoutbaker’s picture

There's no configuration for what you want. Just create your own block to display the logo you want to use.

Vc Developer’s picture

OK Thanks!

raynimmo’s picture

I found this thread whilst searching for the exact same thing, this was the closest I got to the solution.

When I eventually worked it out I thought I would return here to document the solution for others.

I did find on http://dcs777.homeip.net/?q=content/how2-drupal-hacks a method that would work but it suggests you change core files, not really something any decent Drupaler should be doing.

As that posts says, dig through /modules/system/system.module and you will find at the very end of the file the function theme_system_powered_by(), which takes the following form.

/**
 * Format the Powered by Drupal text.
 *
 * @ingroup themeable
 */
function theme_system_powered_by($image_path) {
  $image = theme('image', $image_path, t('Powered by Drupal, an open source content management system'), t('Powered by Drupal, an open source content management system'));
  return l($image, 'http://drupal.org', array('html' => TRUE, 'absolute' => TRUE, 'external' => TRUE));
}

Now you need to create a template.php file in your theme folder if you dont already have one and then append the following code at the bottom.

function your-theme-name_system_powered_by($image_path) {
  //add this line if you want to change the image displayed to something in your theme folder
  $image_path=path_to_theme()."/images/new-image-name.png";

  $image = theme('image', $image_path, t('Powered by Drupal, Drupal Rocks!'), t('Powered by Drupal,  Drupal Rocks!'));

  //add this line if you want the link to open in a new tab/window
  $attrib = array("target"=>"_blank");
  
  //remove the ' 'attributes'=>$attrib, ' if you arent using the open-in-new-tab feature
  return l($image, 'http://drupal.org', array('attributes'=>$attrib, 'html' => TRUE, 'absolute' => TRUE, 'external' => TRUE));
}

This should override the original theme_system_powered_by() function and ensure that future updates dont wipe out your changes.

Make sure to flush your theme registry after updating your files.

Vc Developer’s picture

Excellent research! I shall do as suggested. Thanks!...

treborn’s picture

Here is another way of changing the default "Powered by Drupal" message.

I think this is an example of "Converting from functions to templates" About overriding themable output

As I'm terribly confused by the concepts of 'theme function overrides' and 'preprocess functions' I hope this may help others struggling with these concepts - and welcome any comments that may point to a better explanation within the documentation or indeed correct any misconceptions I may have!

I've found the documentation to be difficult to understand - but the more I experiment the more it is starting to gell!

Mainly I've been trying to get my head around these two documents Creating a sub-theme and About overriding themable output. Also the fantastic Zen documentation found in the various read-me files has been very useful.

I hope this example will help someone else struggling with this concept of themeable over-rides.

The following code needs to go into a file called

system-powered-by.tpl.php

which can be anywhere within your theme folder.

The default place in Zen is the templates folder /sites/all/themes/YOUR_THEME/templates. Initially I named it MYTHEMENAME-system-powered-by.tpl.php, as the documentation seemed to indicate it should be prefaced by your theme name, however that didn't work!

/**
 * @file
 * Using the theme's ability to intercept the 'system_powered_by' function to display basic html as a template rather than a function
 *
 * Original distributed code found in modules/system/system.module
 * Line 3352
 * function theme_system_powered_by() {
 * return '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'http://drupal.org')) . '</span>';
 *
 * @ingroup themeable
 */

$image_path=path_to_theme()."/images/YOUR_IMAGE.png";
print '<span> <a href="a link"><img src="' . $image_path . '" alt="IMAGE_DESCRIPTION"></a></span>';

The only reference I could find about NOT using a function within a 'theme function override' is an old document
template.php: Overriding other theme functions

In trying to re-find where I had seen this advice I came across another article Best practice for declaring functions within '.tpl.php' files? which confirms it is not best practice to use functions within '.tpl.php' files - however no explanation is given. I simply found that a function didn't work.

I'm not using any variables so the simple HTML is fine to do what I want.

I'm using Drupal 7.9 and experimenting with a Zen sub-theme.

raynimmo’s picture

I came across this again whilst searching for an old post,.

I meant to revisit this post last year, when i made the Picon module, which allows for changes to the 'powered by' icon.

see http://drupal.org/project/picon