Advertisement:

Author Topic: Theme Variant per Board  (Read 1106 times)

Offline mabley

  • Jr. Member
  • **
  • Posts: 123
Theme Variant per Board
« on: February 05, 2018, 01:37:21 PM »
I'm using SMF 2.0.15 and building a theme with color variants.

Right now, it's possible to set a theme per board, but I can't seem to set a variant per board. Does anyone know how to do this?

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 17,234
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • aleksi-kilpinen on LinkedIn
Re: Theme Variant per Board
« Reply #1 on: February 11, 2018, 03:56:25 AM »
I don't think that's easily possible without you making a separate theme out of the variants you want to use like that.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.

How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,140
  • Master of BBC Abuse
Re: Theme Variant per Board
« Reply #2 on: February 19, 2018, 03:51:40 AM »
Interesting question. My gut (which admittedly is out of practice on this stuff) is telling me it should be possible. A bit convoluted, but possible. Basically, all you want to do is call CSS by board, for which you in essence just need a CSS file name and a board ID.

All the standard variant system does is set a general call for a variant CSS file in the head section of index.template.php, along with calls for some variant versions of icons in some templates where applicable. So, rejigging that to call a CSS file by board ID or by action should do the trick. I very vaguely remember some such trickery in something I worked on, but offhand I can't remember exactly what it was.

To cut through the BS: yes, it should be possible.

The next question is: why do you want to do it?

Offline drewactual

  • Jr. Member
  • **
  • Posts: 275
    • College Football Fan Site CFB51
Re: Theme Variant per Board
« Reply #3 on: February 20, 2018, 12:26:56 PM »
it doesn't get a whole lot easier than this.   this is a variant of something i picked up here some time back, but can't recall where/who from.  All i did was intro the php include and external file, as well as multiple's by using the elseif operator.

you can use this however you see fit- and it works cleanly in many ways to include full out 'board sensitive' css or simple images... I use it to present a different header image for a board... simply use a php include to a new file you're about to create... in that file:


Code: [Select]
<?php
if(( isset($_REQUEST['board']) && $_REQUEST['board'] == '1' ) || ( isset($board) && $board == '1' )) {
  echo 
'{whatever you want to inject}'; }

elseif(( isset(
$_REQUEST['board']) && $_REQUEST['board'] == '2' ) || ( isset($board) && $board == '2' )) {
  echo 
'{whatever you want to inject}'; }

elseif(( isset(
$_REQUEST['board']) && $_REQUEST['board'] == '3' ) || ( isset($board) && $board == '3' )) {
  echo 
'{whatever you want to inject}'; }

elseif(( isset(
$_REQUEST['board']) && $_REQUEST['board'] == '4' ) || ( isset($board) && $board == '4' )) {
  echo 
'{whatever you want to inject}'; }

elseif(( isset(
$_REQUEST['board']) && $_REQUEST['board'] == '5' ) || ( isset($board) && $board == '5' )) {
  echo 
'{whatever you want to inject}'; }
  
 else {
  echo 
'{whatever your base is}'; }
?>



the area {whatever you want to inject} is where your changes are offered.  you can use css, html, or even another php include if you want (such as you may if you're 'injecting' a large amount of info such as a big css or a big js)...

the area {whatever your base is} is what you want to appear (inject) on a 'standard' page- or left blank between the ' ' to not do anything.... it's there though, if you need it. 

the board numbers you should match up with the boards you intend to use this on.... i just numbered them 1, 2, 3, 4, and 5...

the function is injected on either your index.template, boardindex.template, or message.index template (adjusting accordingly) by a simple php include- such as:
Code: [Select]
include('url to the file you just made');
it's nice that it's an 'include' as it won't break anything if it doesn't work- such as jacked up code (if it's js or php you're 'injecting' that has a syntax error).  if it was 'require' (which you can use, but i wouldn't rec it) it would break the render if it tripped over itself.

at any rate, this is a useful little script to do (if i understand correctly) what you want to accomplish.  I hope you find purpose for it!

https://www.cfb51.com is a College Football Fan Site, Store, and Publisher, launched in July of 2017

Offline mabley

  • Jr. Member
  • **
  • Posts: 123
Re: Theme Variant per Board
« Reply #4 on: February 28, 2018, 06:18:34 PM »
Thank you so much, everyone! Thanks for taking the time to look at my question and offer some information. I'll look into this.