Warning: The author of this contribution does not provide support for it anymore.

Custom Header Logo

Different logo for different theme - Custom Header Logo

Different logo for different theme

by Michal01 » Tue Oct 30, 2012 11:32 am

Hey, great job. Help me solve this. Sorry my English is google translator.
In the forum they are running 2 active style. I want logo1 for prosilver style. Logo2 for style Proglas. I want to index page in style prosilver logo was different than the index page Proglas theme.
How to set up to display different logos on different themes?
Thank you for your help
Michal01
Registered User
Posts: 1
Joined: Tue Oct 30, 2012 11:19 am
Location: Slovakia
Contact:

Re: Different logo for different theme

by Balint » Fri Nov 09, 2012 7:31 pm

Hello to Slovakia and sorry for the late reply. The feature you are requesting is currently not available. Most of the users only use one style. Maybe in a future version I'll implement it.
User avatar
Balint
Registered User
Posts: 952
Joined: Tue Aug 06, 2002 2:19 pm
Location: Germany
Contact:

Re: Different logo for different theme

by Skouat » Sun Dec 02, 2012 10:32 am

Hi Balint,

It's true that most of the users only use one style.
In my case, i use 1 style throughout the year, except for specific events like "Haloween", "Begining of the summer"...

it would be nice if you could add this feature.

Regards.
Skouat
Code Contributor
Posts: 767
Joined: Mon Mar 10, 2008 5:30 pm
Location: France
Contact:

Re: Different logo for different theme

by Ledsen Arkangel » Mon Apr 22, 2013 3:15 pm

Sorry if I shouldn't write this here, but in case that someone is interested... I was actually searching a way to store imageset images outside the forum root path (found that, too) and somehow as a result, I ended up in this. I'm not sure if anyone needs that anymore, but just for the exercise, a reeeeeally simple solution:

1. Repeat this step to every style you want to show custom header images:
COPY images/backgrounds/*.* to styles/[style]/theme/images/backgrounds/*.*
COPY images/logos/*.* to styles/[style]/theme/images/logos/*.*

2. OPEN includes/fuctions.php
FIND

Code: Select all

         if (!empty($site_logo_custom))
         {
            $site_logo = '<img src="' . $phpbb_root_path . 'images/logos/' . $site_logo_custom . '" alt="" title="" />';
         }
         if (!empty($header_background_custom))
         {
            $site_background_logo = $phpbb_root_path . 'images/backgrounds/' . $header_background_custom;
         }

REPLACE WITH

Code: Select all

         if (!empty($site_logo_custom))
         {
            $site_logo = '<img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/logos/' . $site_logo_custom . '" alt="" title="" />';
         }
         if (!empty($header_background_custom))
         {
            $site_background_logo = $phpbb_root_path .'styles/' . $user->theme['theme_path'] . '/theme/images/backgrounds/' . $header_background_custom;
         }


FIND

Code: Select all

      'SITE_LOGO_IMG'         => $site_logo,

REPLACE WITH

Code: Select all

      'SITE_LOGO_IMG'         => $user->img('site_logo'),
      'SITE_LOGO_CUSTOM_IMG'         => $site_logo,


3. Repeat this step to every style you want to show custom header images:
OPEN styles/[style]/template/overall_header.html
FIND

Code: Select all

{SITE_LOGO_IMG}

IN-LINE FIND

Code: Select all

{SITE_LOGO_IMG}

IN-LINE REPLACE WITH

Code: Select all

{SITE_LOGO_CUSTOM_IMG}


4. Repeat this step to every style you do not want to show custom header images:
(if you have done the file edits during mod installation to them, that is)
OPEN styles/[style]/template/overall_header.html
for prosilver-based styles FIND AND DELETE

Code: Select all

<!-- IF SITE_BG_IMG -->
<style type="text/css">
<!--
.headerbar {background:url("{SITE_BG_IMG}") repeat;}
-->
</style>
<!-- ENDIF -->

for subsilver2-based styles FIND AND DELETE

Code: Select all

<!-- IF SITE_BG_IMG -->
<style type="text/css">
<!--
#logodesc {background:url("{SITE_BG_IMG}") repeat;}
-->
</style>
<!-- ENDIF -->

If you haven't done the template edits during mod installation to styles you don't want to show custom header images, you of course don't need to find and delete anything... just don't add the edits to them, and you'll be fine.

5. If you have multiple styles that use the same template files, and you want some of them to not show custom header images while others show them, you need to do an additional trick:
OPEN styles/[style]/template/overall_header.html
FIND (skip this, if you don't find any)

Code: Select all

<!-- IF SITE_BG_IMG -->

REPLACE WITH

Code: Select all

<!-- IF SITE_BG_IMG and T_STYLESHEET_NAME neq 'name of the style' and T_STYLESHEET_NAME neq 'name of the style' -->

Replace name of the style with the name of your style you don't want to show custom header images. You can add as many and T_STYLESHEET_NAME neq 'name of the style's as you need (one for every style you don't want to show custom header images, but that should be obvious).

if you didn't add the edit I gave in number 3, FIND and IN-LINE FIND

Code: Select all

{SITE_LOGO_IMG}

if you did, FIND and IN-LINE FIND

Code: Select all

{SITE_LOGO_CUSTOM_IMG}

either way, IN-LINE REPLACE WITH

Code: Select all

<!-- IF T_STYLESHEET_NAME eq 'name of the style' or T_STYLESHEET_NAME eq 'name of the style' -->{SITE_LOGO_IMG}<!-- ELSE -->{SITE_LOGO_CUSTOM_IMG}<!-- ENDIF -->

Replace name of the style with the name of your style you don't want to show custom header images. You can add as many or T_STYLESHEET_NAME eq 'name of the style's as you need (one for every style you don't want to show custom header images, but that should be obvious... I have a feeling that I'm repeating myself).

6. Save the files and refresh the templates. We're finished.

Text looks long, but the code changes are quite minor. Maybe not the most elegant solution, as you can't set forum X to have style-specific header image while forum Y has not - it's all or nothing - but hey, that kind of functionality wouldn't be a simple edit anymore. It would be a full-sized add-on (though I am working on it right now, writing this made me interested).

Some notes:
  • Only thing that edit changes is the place, where images are searched when you view the page they are set to show. So the images are viewed from styles/[current style]/theme/images/, not the [forum root]/images/.
  • The image files in the dropdown box in ACP, where you set which image you want to show where, are still listed from [forum root]/images/backgrounds/ and [forum root]/images/logos/. The files must still be there. Hovewer, we need only their filenames, so they don't need to be full-sized header images; 1px x 1px placeholders will go fine.
  • File names in styles/[style]/theme/images/backgrounds/ must be same than in [forum root]/images/backgrounds/ as well as file names in styles/[style]/theme/images/logos/ must be same than in [forum root]/images/logos/. Otherwise you won't see the logos and backgrounds at all (or you see "image not found" -notification, which is even worse). The images themselves can be whatever you want, as long as you remember to keep the filenames same.
  • If you, for some reason, want to have, say, forum X to have a custom logo in style A but not in style B, you need to create three images: let's say you use logo with filename "forum_x.png". So, you put a 1px x 1px "forum_x.png" into [forum root]/images/logos/, then your custom and full-sized "forum_x.png" into styles/styleA/theme/images/logos/, and finally a copy of forum X:s default logo - board's default logo, or forum X:s parent forum's custom logo - (renamed from, say, "default.png" to "forum_x.png") into styles/styleB/theme/images/logos/. Then go to ACP and set forum X to have custom logo "forum_x.png". That should do the trick.
  • But then, if only thing you want is to have one style that uses custom header images and other that doesn't, you don't need to do step 1 at all, and from step 2 you need to do only second edit (that separates the "normal" header image and the custom header image). From step 3 to end as usual. With that way you can have a style that doesn't use custom header images at all, and other style(s) that use them normally (=images from images/logos/ and images/backgrounds/).

...maybe I just should stop writing as long as I still understand what I'm writing... I'm not so sure about that I do anymore, though. Hopefully that text makes any sense to anyone who happens to be interested, anyway.
Ledsen Arkangel
Registered User
Posts: 16
Joined: Wed Aug 24, 2011 1:20 pm