Hi all,

Is there someone who find a way to change the logo when you change page?

For example, I could do a home page, a support page, and a contact page with all different logos.

I could use the taxonomy theme module, but that would require to have a different theme for all pages.

Thanks.

Comments

chlobe’s picture

what the responses to this question are - forgive my transparent way of tracking this node :)

I'm trying something similar and started by using the banner module (there is a cvs update for 4.7). Seems to be working okay but somewhat restricted by themes.

pobster’s picture

Surely it'd be easier to write some php (a module) to rename a selection of say, png logos from 1.png, 2.png, 3.png, etc... to logo.png on every page change? Something like:

function logo_changer_init() {
  $logos = file_scan_directory(drupal_get_path('module', 'logo_changer'), '.png$');
  $logo = array_rand($logos);
  $action = file_copy($logo, 'a path to where your logo is stored...png', FILE_EXISTS_REPLACE);
  if (!$action) {
    watchdog('logo_changer', t("There's been an error with this file - '%file'", array('%file' => $logo)), WATCHDOG_ERROR);
  }
}

You'd probably need to flush the cache or something afterwards? But I can't see a reason why it wouldn't work? Obviously you could be clever with it and fetch the page you're on and use that as a reference to display a logo accordingly. Just a thought...

Pobster

pobster’s picture

If anyones interested, I'm releasing a module soon:

http://drupal.org/project/logotool

A simple utility to display either a random logo on every page, else display a specific logo on a specified page.

To use, simply install the module and enter your preferred settings in 'admin/settings/logotool'. Then uncheck your themes 'Use the default logo', then point the 'Path to custom logo' to:

logotool/logo

Pobster

chlobe’s picture

I look foward to testing it this week.

alexandreracine’s picture

Great! I can't wait to try it!

Is this for 4.6 or 4.7? (no problem, I'll just use the good version)

Thanks.

Alexandre Racine

www.gardienvirtuel.com Sécurité informatique, conformité, consultation, etc

www.salsamontreal.com La référence salsa à Montréal

pobster’s picture

Okay it's fully working for 4.7 now and it should be very easy to port to 4.6 if anyone requires it? Raise an issue on the module page if you do, I'm not going to just go ahead and write it as I don't currently have a 4.6 installation and so will have no way to test it...

Pobster

alexandreracine’s picture

Work pretty nicely, well... for the random part.

I'll send my comment / bug in the project page.

http://www.alexandreracine.com/demo/page1

Alexandre Racine

www.gardienvirtuel.com Sécurité informatique, conformité, consultation, etc

www.salsamontreal.com La référence salsa à Montréal

smikey’s picture

Hello;

Just recently installed the Logo Tool module, and am sold on the concept (esp. because my client asked for the feature)…

My issue is that I’m unable to view the logos I placed in the modules/contrib/logotool/logos folder. I’ve set the directory and all the files to read CHMOD 777 so the server being able to access the files should be ruled out.

My reckoning is that I have everything pointing to the wrong path to the files. So my question is where I’ve gone wrong. Here’s what I have:

Path to default/ main logo:
/home/media911/public_html/drupal-4.7.2/modules/contrib/logotool/logos/default

Path to your logos folder:
/home/media911/public_html/drupal-4.7.2/modules/contrib/logotool/logos

Display mode:
Random logos

Specific logos for specific pages:
Blank

And here’s what I have my themes settings set to:

Path to custom logo:
logotool/logo

Upload logo image:
Q – Should I upload a custom logo image or leave it blank? I tried to upload aa logo manually, and I could see the file, so I guess the files can be read.

Yikes, and I have a deadline, so I’m almost at the point of loosing sleep!!! Hope this helps. Thanks for reading this…

~Michael

pobster’s picture

Why would you want to place your modules folders in /modules/contrib/...? I somehow doubt that's the issue here but it seems bizarre to me that you thought that would be a good idea?! If you've simply sync'd the cvs branch to your modules directory then trust me on this and REMOVE IT, you'll hit all sorts of issues especially memory problems... Anyways... /modules/... is the standard normal persons way to avoid unnecessary heartache...

Path to default/ main logo:
/home/media911/public_html/drupal-4.7.2/modules/contrib/logotool/logos/default

Doesn't make any difference to anything regarding whether it works or not - but how comes 'default' doesn't have a file extension? It is an image file right?

Path to your logos folder:
/home/media911/public_html/drupal-4.7.2/modules/contrib/logotool/logos

Looks fine - but can you type http: //www.yoursite.com/drupal-4.7.2/modules/contrib/logotool/logos/logo.png and view a logo? If not... *sigh* I'll talk you through how to do it, but I really shouldn't as it's got nothing to do with Drupal... You'll need to set up your <directory> settings properly in your webserver. Either that or you overlooked something with your permissions?

Path to custom logo:
logotool/logo

Also looks fine, but do you have it set for your global settings or your current themes settings? You've not actually told me what happens/ what the problem is? Only that it doesn't work... It's a little irritating to have to list every single thing you might have done wrong here... Maybe you could actually let me know? One thing though, if your theme is displaying a default logo then well, perhaps a little common sense is called for with regards global settings vs. theme settings... ;o)

So... Tell me what happens and I'll tell you how to fix it. Also, tell me what appears in your logs when you view the logotool subpage which lists all your logos.

Pobster
PS.

Upload logo image:
Q – Should I upload a custom logo image or leave it blank? I tried to upload aa logo manually, and I could see the file, so I guess the files can be read.

Eh??? That's got absolutely nothing at all to do with the module? That's a standard form for customizing a logo... I'm starting to worry that your problem is lack of understanding of terminology... PLEASE tell me this is not the case...?

blueroo’s picture

I don't think my image files are in the right folder, even though they are in the logos folder under the logotool folder. So, in this line of the module code:

define('LT_CWD', dirname(__FILE__).'/logos');

what path does __FILE__ refer to?

pobster’s picture

You again? ;o) If you look at the frankly weird issue you've created you'll see that I've explained the entire module process to you.

http://www.google.co.uk/search?q=__FILE__

It doesn't take much ;o) *sigh* __FILE__ reflects the absolute path of the file which called it, therefore for most 'LT_CWD' will point to '/var/www/localhost/htdocs/modules/logotool/logos'

...If you're using a version of php4 older than php4.1.2 then you'll have problems... But seeing as the most current version of php4 is php4.4.4 I doubt that's the issue here. I use php5 myself which works flawlessly.

Pobster

alexandreracine’s picture

Just for the 777 part. You don't need to chmod 777.

Why should everyone be able to read write and execute?

Your error is coming from somewhere else...
Read the install file carefully and slowly :)

Alexandre Racine

www.gardienvirtuel.com Sécurité informatique, conformité, consultation, etc

www.salsamontreal.com La référence salsa à Montréal