miniBB Support Forums | 15 years on The Web
miniBB ®

miniBB

®
  
 | Begin | Register | Reply | Search | Statistics | Manual |
Specific miniBB Support Forums / Specific /   
 

New Background For Specific Topic?

 
Author dan12343
Partaker
#1 | Posted: 31 Jul 2016 18:22 
Is there a way to have a special background image for a specific topic? It would be really great if I can do that

Author tom322
Active Member
#2 | Posted: 31 Jul 2016 21:04 
Yes, do you want it just for one topic? Give an example.

Author kuopassa
Partaker
#3 | Posted: 31 Jul 2016 22:03 
I've got a simple idea for this. :-) Put this in plugins.php:

if ((isset($_GET['topic'])) && (isset($_GET['forum']))) {
$topic_css_selector = ' class="topic-id-'.filter_var($_GET['topic'],FILTER_SANITIZE_NUMBER_INT).'"';
}

And this in templates/main_header.html inside <body> tag:

{$topic_css_selector}

So that it looks something like this:

<body{$topic_css_selector}>

After that when user is viewing any topic, there's a CSS class selector that you can use. So for example if user is viewing topic with ID 30, then you have this HTML:

<body class="topic-id-30">

That means you can write CSS for that, like:

body.topic-id-30 { background: #eee; }

Author dan12343
Partaker
#4 | Posted: 1 Aug 2016 00:42 
kuopassa: Thanks a bundle for the elaborate response. At what part of your solution do I identify the topic name or number? And will your solution work for a (tiled) background image? Can I embed a sound also just for that topic? Will this be applied to all posts within the topic as well? Sorry for the many questions

tom322: Well for now just one topic, but if I can set special backgrounds for each topic I may do a few more


Thanks all

Author dan12343
Partaker
#5 | Posted: 1 Aug 2016 00:49 | Edited by: dan12343 
One other thing;

In header_main.html of my board I have site title images. Can I also change the images on header_main using this solution? That would be perfect

Thanks again and sorry for double bump

Edit: I now see where the topic number is identified

Author kuopassa
Partaker
#6 | Posted: 1 Aug 2016 03:59 
Hey, dan, thanks for the battery of questions. :-)

- This code should be applied to all pages in that topic and all posts if you want to by writing a suitable CSS "code".

- Sound file is not possible to load with CSS, but you could modify the PHP code and create another tag that goes inside templates/main_header.html, one that for example loads JavaScript and/or HTML.

- I don't think title images can be changed with this solution if you have them as <img /> tags in HTML template.

Here's an example how you could change the background of a specific topic with CSS:

body.topic-id-30 {
background: #fff url('background-for-topic-30.jpg') no-repeat 0 0;
}

And same thing for individual posts (if you use the same theme as in this forum or in miniBB demo forum):

body.topic-id-30 table.forums {
background: #fff url('background-for-posts-in-topic-30.jpg') no-repeat 0 0;
}

Author dan12343
Partaker
#7 | Posted: 1 Aug 2016 05:58 
I guess I should've been more specific, rather than Topic as in a post, I meant to ask can I change the background for a subforum-topic?

Author dan12343
Partaker
#8 | Posted: 1 Aug 2016 06:25 
I see you mean topic and forum are same thing. My MiniBB board is modified to run well on Sega Dreamcast. So I think the CSS for the regular theme is broken and this solution will not work. Am I right? I tried it and it didn't work so I figured your solution was for posts

One of the games used to have a forum accessible in-game. And this would replace that. But I'd like to replicate the original the best I can without a second minibb install

Is there a possible plugin code for a specific forum/topic to use new template files, which replicate the originals but have the new background image? Actually If I can use another main_header file I can just change the bg image there without modding anything else. That way is messy, but I'm using very old browsers for it (But MBB works great for this)

I also appreciate the in-depth help. This would be quite a nifty plugin to add to the official list

Author Paul
Lead Developer
#9 | Posted: 1 Aug 2016 19:09 | Edited by: Paul 
dan12343:
What kuopassa suggested above, is the most proper solution for you. Still, you would need to clarify, if you want to set up a different background for a specific forum, or for a specific topic. When we are now, is a topic. Forum is here, for example.

In any case, in bb_plugins.php you could code a different body CSS for either forum or topic. Use $topic or $forum vars for this. In the below code, I'm coding this for a specific forum with id=1. Here's how to determine the forum ID.

$specific_body_css='';
if($forum==1){
$specific_body_css=' classname';
}

Then you shall put something like in main_header.html:

<body class="gbody{$specific_body_css}">

In CSS file, specify .classname in the way you want.

In the same way you could set any specific HTML for audio files etc. For example:

$specific_html='';
if($forum==1){
$specific_html=<<<out
Your HTML code here
out;
}

Then paste {$specific_html} in any template you want.

Author dan12343
Partaker
#10 | Posted: 1 Aug 2016 21:34 
Hmm yes that seems perfect. The platform this is intended for doesn't really support CSS, so I would put the entire main_header html in the $specific_html var if the topic number is 1 in this case. But how can I write the rule that if the forum number is not 1, it will use html for the regular main_header?

So main_header.html would just be

{$specific_header}

Then in bb_plugins.php

$specific_html='';
if($forum==1){
$specific_html="Entire main_header html"
}
if($forum==(not 1){
$specific_header="Entire regular header"
}

I understand coding a lot, but I can't actually code. So forgive me for asking how to declare that. This way if it works, I can declare it for multiple forums and add whatever new scripts/sounds/images all in one go. As well as in the posting area and viewing posts in those specific forums

Author dan12343
Partaker
#11 | Posted: 2 Aug 2016 01:29 
Paul's HTML solution works perfectly. Thanks a lot

The only thing is I want to change the header images too. Is there a way I can define if the topic number is not specified it uses original HTML, and if the forum number is defined it uses the new HTML

I'm just not familiar with the php syntax to say "if the number is not 1 or 2"
I'd like to do this for multiple forums, so if I can define once to display the original HTML I can add it to multiple forums

Thanks again, and I'll post the code I have now later so it helps anyone in the future

Author tom322
Active Member
#12 | Posted: 2 Aug 2016 02:40 
if($forum!=1) //if forum is not 1
if($forum!=2) //if forum is not 2

if($forum!=1 and $forum!=2) //if forum is different from 1 or 2 (if forum is neither 1 or 2)


Author DavidBennett
Partaker
#13 | Posted: 16 Sep 2016 15:51 
Thanks Kuopassa for sharing this ..I would definitely like to try out this .

Author samson
Partaker
#14 | Posted: 8 Oct 2016 00:57 
dan12343
I find that very helpful. Keep up.

Specific miniBB Support Forums / Specific /
 New Background For Specific Topic?
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


 ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
↑ TOP