Template Inheritance Coming Soon
In this post on the official phpBB.com blog the development team has announced something really cool that came out of Londonvasion… template “fallback” system. It’s one of those changes that makes you think, “Hey, why didn’t someone notice that before?”
I am not a template / styles person. Oh, I claim to do web design (and it says so on one of my other sites
) but what I am really best at is designing the function and structure of a site. I will often contract with someone to do the presentation layer. But I do understand how the phpBB template system is structured. Each style has a directory with the template files in it. If I want to make a minor change, I can copy the entire directory, make my change, and create my new style. If there is an update to the core code, then I have to change each and every template directory. This is one of the reasons why I posted more than a year ago ago about having more than one style for a board being a silly idea. Now that’s changed with this new feature.
In the next release (the blog post suggested that this would be included in 3.0.3) a style can be duplicated by copying only the files that you need to change, and leaving the rest in the source folder. This came about as a result of a conversation with one of the former Joomla! guys that was at Londonvasion demonstrating some of the very cool styles his group was in the process of creating. As an off-hand remark he said that developing styles for phpBB3 was hard because of the number of files you had to include. One of the developers picked up on that, and the next thing you know, we have template inheritance.
In the template you can now point to a parent template source directory. Any file that is missing in the current template directory is simply replaced by the equivalent file in the parent source directory. It’s just that simple.
They’re only going to support one level of inheritance for now, which is probably enough. Many styles are loosely based on other styles, and many share a common ancestor in prosilver or subSilver2, so I expect that one level is enough for now. And who knows, they might go with unlimited levels in a future release… wouldn’t that be fun to debug?
Congratulations to the developer team, and well done.


The most fun thing about an unlimited level of inheritance would be recursion
.
Comment by eviL3 — August 11, 2008 @ 11:41 am
This is a feature of XS for v2, I believe. But then again, the selling point is that it is built-in to phpBB 3 versus being a 3rd-party add-on.
Comment by Dog Cow — August 11, 2008 @ 2:48 pm
Dog Cow: I wasn’t aware of this feature for eXtreme Styles… but then again I never tried it. I knew that XS did quite a few things. For example, it would auto-fill language strings that were missing. XS also was – interestingly enough – not the best performer when I did some benchmark tests a while back.
And yes, evil3, have to detect recursion would be one reason to not offer unlimited inheritance.
Comment by Dave Rathbun — August 11, 2008 @ 3:44 pm
I have been using XS for the past two years up until last night when I finally switched to Speedy. I had to go through _many_ files and put in the L_ variables by hand. Fortunately, what I did was change XS so if it was about to default to a $lang var, it would shout LANGUAGE VAR MISSING!!!!! at me, and that was my cue.
Also, it saved me about one tenth of a second as well as 200 KB of RAM.
Comment by Dog Cow — August 12, 2008 @ 1:26 pm
XS is certainly a RAM hog.
When I turned it off I found a few language variables missing, but not that many. FWIW, I’m not using speedy at the moment as I found some sort of problem with it; it would generate empty output for certain pages on my board and I haven’t had time to fully investigate. If my memory is correct, one of the pages was the posting page, and an empty posting page is a bit of a problem.
Comment by Dave Rathbun — August 13, 2008 @ 12:10 am
I have had no problems with white pages, where Speedy is concerned. The only time I get those is when PHP errors or notices come up, or I am echo()’ing stuff above the header AND I have GZip enabled.
So… when I am debugging/programming I turn off Gzip, and when I am all finished, I turn it back on.
Comment by Dog Cow — August 13, 2008 @ 11:46 am
I don’t use gzip. I would rather pay the cost for the extra bandwidth and save server CPU resources.
Comment by Dave Rathbun — August 13, 2008 @ 1:23 pm