Banners change by category/board

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
User avatar
Gumboots
Registered User
Posts: 801
Joined: Fri Oct 11, 2019 1:59 am

Banners change by category/board

Post by Gumboots »

Not sure if anyone has played with this idea yet (someone probably has) but a search didn't turn up anything obvious.

It started with me running a bit of custom CSS in Stylish to override some of this site's code. Then I got to thinking it'd be fun to have the option of different banners per category and/or per board, and to have them scale with window width. So I loaded Prosilver_SE on local and messed around with it (this was basically an exercise in me trying out how to do conditionals in phpBB syntax).

Have got it sorted, and it works in Firefox, Opera (which means Chrome too), Pale Moon and IE11. This code posted just for fun, in case anyone finds any of it useful.

It requires one small edit in overall_header.html. A similar conditional could be applied to any style.

Find:

Code: Select all

			<div id="site-description" class="site-description">
				<a id="logo" class="logo" href="<!-- IF U_SITE_HOME -->{U_SITE_HOME}<!-- ELSE -->{U_INDEX}<!-- ENDIF -->" title="<!-- IF U_SITE_HOME -->{L_SITE_HOME}<!-- ELSE -->{L_INDEX}<!-- ENDIF -->"><span class="site_logo"></span></a>
Replace:

Code: Select all

			<div id="site-description" class="site-description">
				<a id="banner_<!-- IF S_FORUM_ID -->{FORUM_ID}<!-- ELSE -->0<!-- ENDIF -->" class="logo" href="<!-- IF U_SITE_HOME -->{U_SITE_HOME}<!-- ELSE -->{U_INDEX}<!-- ENDIF -->" title="<!-- IF U_SITE_HOME -->{L_SITE_HOME}<!-- ELSE -->{L_INDEX}<!-- ENDIF -->"><span class="site_logo"></span></a>
That sets banner id to #banner_0 for the board index, or any other url without a forum id number, and sets id to #banner_x where FORUM_ID == x. Then you can just stack up as many banners as you like in your CSS files, and call them for whatever categories/boards you like.

The CSS I'm running is just appended to the end of Prosilver_SE's stylesheet.css. Looks like this:

Code: Select all

.copyright {
	color: #bbb;
}
.copyright a {
	color: #000000 !important;
	color: #8AB1D3 !important;
}

li.row {
	background-color: #E8ECEE;
}

li.row:hover {
	background-color: #EBEFF1;
}

li.row.bg3 {
	background-color: #F0F4F6;
}

li.row.bg3:hover {
	background-color: #F4F8FA;
}

.site_logo {
	background-image: url("./images/site_logo.gif");
}

/* @Gumboots - trial additions. */
.forabg .topics, .forabg .posts,
.forumbg .posts, .forumbg .views, .header .lastpost {
	display: none;
}
html {
	background: #214770;
}
body {
	padding: 26px 0 0;
	background: linear-gradient(#111E2C, #214770 300px);
}
#wrap {
	max-width: 1024px;
	min-width: 290px;
	margin: 0 auto 20px;
	padding: 14px 24px;
	background: #fff;
	background-image: linear-gradient(#dfdfdf, #fff 152px);
	box-shadow: 0 0 5px 2px rgba(0,0,0,.7), inset 0 3px 18px rgba(100,100,100,0.25);
}
.headerbar {
	margin-bottom: 1px;
	padding: 0;
	background: none;
}
.headerbar .inner {
	position: relative;
}
.site-description {
	float: none;
	width: 100%;
	height: auto;
}
.site-description .logo {
	float: none;
	width: 100%;
	padding: 14.29% 0 0;
	height: 0;
	background-size: contain;
	border-radius: 7px 7px 0 0;
}
#banner_0 {
	background-image: url("images/banner_1.jpg");
}
#banner_39 {
	background-image: url("images/banner_2.jpg");
}
#banner_1 {
	background-image: url("images/banner_3.jpg");
}
#banner_52 {
	background-image: url("images/banner_4.jpg");
}
#banner_10 {
	background-image: url("images/banner_5.jpg");
}
#banner_49 {
	background-image: url("images/banner_6.jpg");
}
#banner_50 {
	background-image: url("images/banner_7.jpg");
}
#banner_51 {
	background-image: url("images/banner_8.jpg");
}
#banner_81 {
	background-image: url("images/banner_9.jpg");
}
#banner_43 {
	background-image: url("images/banner_10.jpg");
}
.site_logo {
	display: none;
}
.site-description h1 {
	position: absolute;
	top: 1.3em;
	left: .5em;
	margin: 0;
}
.site-description p:not(.skiplink) {
	position: absolute;
	top: 5em;
	left: 1em;
}
.search-header {
	border-radius: 0;
	display: block;
	float: none;
	overflow: hidden;
	margin: -1px 0;
	padding: 4px;
	background: linear-gradient(#474F55, #7C8891);
	box-shadow: none;
}
.search-header #search {
	float: right;
}
#page-header .navbar {
	margin: 0 0 4px;
	background: #e8ecee url("/assets/images/images/silver/row_bg.gif");
	border: solid #7C8891;
	border-width: 0 3px 3px;
	border-radius: 0 0 5px 5px;
}
.responsive-center.time {
	margin: 0 4px 1.5em;
}
.action-bar {
	font-size: 11px;
	margin: 4px;
}
.forabg, .forumbg {
	padding: 5px 5px 4px;
	border-radius: 8px 8px 5px 5px;
}
.forums {
	border-radius: 0 0 3px 3px;
	overflow: hidden;
}
.header dt {
	padding: 0 9px 2px !important;
	font-size: 15px !important;
	font-weight: 500 !important;
	text-transform: capitalize !important;
}
.collapse-btn {
	margin: -22px 0 0;
	opacity: .4;
}
.collapse-btn:hover {
	opacity: .75;
}
ul.topiclist dt .list-inner {
	margin-right: 260px;
}
ul.topiclist .lastpost, ul.topiclist .redirect {
	float: right;
	width: 260px;
}
@media (max-width: 1200px) {
	#wrap {
		max-width: 88%;
	}
}
/* responsive.css changes */
@media only screen and (max-width: 860px), only screen and (max-device-width: 860px) {
	#wrap {
		width: auto;
	}
}
@media (max-width: 700px) {
	body {
		padding: 0;
	}
	#wrap {
		max-width: 100%;
		margin: 0;
		padding: 0 5px 5px;
		border: 0;
		border-radius: 0;
	}
	.site-description .logo {
		display: block;
		border-radius: 0;
	}
	.site-description h1 {
		top: .7em;
	}
	.site-description p:not(.skiplink) {
		top: 3.2em;
		left: .5em;
	}
	.site-description p, .search-header {
		display: block;
	}
	#page-header .navbar {
		margin: 0 -5px 4px;
		border-radius: 0;
	}
	.forabg, .forumbg {
		padding: 5px 3px 3px;
		border-radius: 0;
	}
	li.header dt {
		text-align: start;
	}
	ul.topiclist dt .list-inner {
		margin-right: 0;
	}
  }
The real trick here is to match to top padding on .site-description .logo to the proportions of your banner image. I was using a 1400x200 banner, so height is 1/7 of width, or 14.29%. If you had a 1400x100 banner you'd use 10% top padding. If you had a 1400x350 banner you'd use 25% top padding.

Note that some parts of that code will also hide the posts/topics columns, because I think they're boring and I don't want to look at them, but you can remove those parts if you love looking at stats. I prefer to just see the content that interests me.

I also tweaked the paddings and border-radius on forabg/forumbg and the child lists. I think the default bottom corners are a bit wrong. The lower corner of the li is too close and too square compared to the wrapper, and looks sorta like bones poking out through skin. IMO a slight tweak makes them look smoother and more harmonious. ;)

Wide_trial.jpg
Narrow_1.jpg
Narrow_2.jpg
Narrow_3.jpg
You do not have the required permissions to view the files attached to this post.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
Lumpy Burgertushie
Registered User
Posts: 69228
Joined: Mon May 02, 2005 3:11 am

Re: Banners change by category/board

Post by Lumpy Burgertushie »

good work. just FYI, there have been MODs and now extensions that do this for quite some time.


robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
Gumboots
Registered User
Posts: 801
Joined: Fri Oct 11, 2019 1:59 am

Re: Banners change by category/board

Post by Gumboots »

Not surprised, but I couldn't find any after running a couple of searches. I'd be inclined to build this into any style I made, just because I can. ;)

ETA: Oh, I know there's a banner extension that puts one custom banner up, and I know there's another one that allows a stack of random banners.

My code doesn't do either of those things. It allows setting a specific banner for each category or board. And obviously you can call the same banner for multiple boards if you want to (ie: if you want all boards in a category to have the same banner) just by tying the multiple forum id's to the one image (#banner_1, #banner_2 {background: etc...).
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦

Return to “[3.2.x] Styles Support & Discussion”