News:

Wondering if this will always be free?  See why free is better.

Main Menu

Board theme templates and fallbacks?

Started by Peter Duggan, January 24, 2015, 04:13:50 PM

Previous topic - Next topic

Peter Duggan

First time I've posted anything here for years, but a quick question because a quick search isn't telling me quickly...

If I want to change theme to utilise a single different template (let's call this 'Theme A') for a couple of boards on a forum already using a non-default theme ('Theme B'), do I have to copy all my Theme B templates to Theme A or can Theme A be configured to fall back on Theme B like Theme B falls back on the default for shared templates?

Thanks
P

Kindred

No, you can not make it fall back to theme a...

So, the answer is, yes...  You will have to copy ALL files from theme a into theme b if you want to use theme a as a baseline.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Peter Duggan

OK, thanks... had already started playing on that assumption, but helpful to be sure!

Cheers
P

Illori

Quote from: Kindred on January 24, 2015, 06:57:03 PM
So, the answer is, yes...  You will have to copy ALL files from theme a into theme b if you want to use theme a as a baseline.

actually not true. if when you install the theme it has <based-on> tag defined in theme_info.xml you can fall back on files from another theme. very few themes seem to use this feature though. i am not sure which files it falls back on using though.

Quote from: Runic on January 21, 2012, 08:53:53 AM
Finally we have based on (<based-on></based-on>), firstly this one has caused a lot of scratching heads specially recently in the uber top secret world domination meetings.  This has been an interesting one, until recently we were under the impression that this was more to do with creditation, however with thanks to new eyes it has been brought to our attention it actually does more and will call on files from the theme mentioned in the based-on tag if its installed.  This we do wish to apologise on, as this was never realised until now. This also shows you on why proper documentation is important.

Bloc

I would think it first checks current theme - then the "based-on" theme , and finally, default theme, if all else fails.

This goes for templates. Styles and images still come from current theme.


// Based on theme (if there is one).
if (!empty($settings['base_theme_dir']))
$settings['template_dirs'][] = $settings['base_theme_dir'];

// Lastly the default theme.
if ($settings['theme_dir'] != $settings['default_theme_dir'])
$settings['template_dirs'][] = $settings['default_theme_dir'];


So you could make a theme that tries to be a "based-on" theme, if the based on-theme is actually installed its using it for its templates, if not it will just use default theme, as normal. I have never tested this though, but the code suggest it should work.(SMF 2.0.9)

Bloc

Heh, this could actually make way for making a alternative "default" theme..where later/other themes would then be "based-on". If that "default" theme replace all or most templates, it would BE your default fallback theme. :D

Peter Duggan

Quote from: Bloccy on January 25, 2015, 07:51:29 AM
So you could make a theme that tries to be a "based-on" theme, if the based on-theme is actually installed its using it for its templates, if not it will just use default theme, as normal. I have never tested this though, but the code suggest it should work.(SMF 2.0.9)

I've just been trying this and couldn't make it work. Not a big issue because even my 'based-on' theme doesn't change that much from default and I can live with duplicating a handful of templates, but I'll maybe go on playing with it anyway and report back if I get it sussed.

Bloc

#7
Hm, I did get it to work fine..but the "based on" theme HAVE to be same name and path. Meaning "MyBase" would need to be in "MyBase" folder too, for others to use it. Your theme then use <based-on>MyBase</based-on>.

It seems to also load the based-on theme's index.template..which is not always desired, have to check more on that.

EDIT: no, it works as it should, also with index.template. :) If you REMOVE your themes index.template, it WILL use based-on theme index.template...and so on.

Antechinus

Quote from: Bloccy on January 25, 2015, 07:54:07 AM
Heh, this could actually make way for making a alternative "default" theme..where later/other themes would then be "based-on". If that "default" theme replace all or most templates, it would BE your default fallback theme. :D

I had already thought of doing this. :D

Bloc

:) I envisoned having to make a mod out of making an alternative default theme co-exist with default..but it seems the solution was there all along.

- Jumping to mind: a way to make sure you ONLY loaded the css from a subtheme + any custom templates. Would allow for a basetheme to all the heavy-lifting, but css is taken from a subtheme. Or the basetheme could check for a function that only exist in a template that any subtheme supplied(you can add any templates to auto-load in the xml file. Normally it just says "index" there ) and from that load the css files. (of course this breaks currently what SMF 2.1 does with its loadCSS function..but who cares lol)

Heh :) This is interesting stuff indeed!


Antechinus

My thinking about this was related to Apocalypse. It's close to being a "new 2.0.x default theme" anyway, so using the based-on trix with it seemed to make sense. Arantor did caution that it could be rather brittle in practice, but I haven't played with it yet.

Bloc

In what way?

Templates would be checked in order "current theme"/"based on" theme/default. It will find its target eventually.

Antechinus


Peter Duggan

Quote from: Antechinus on January 26, 2015, 03:54:55 PM
Not sure in what way. Didn't really pursue it at the time. Thread was here: http://www.simplemachines.org/community/index.php?topic=528350.0

Interesting... and presumably missed by my search because I was using slightly different terms for the same thing.

Quote from: Arantor on September 29, 2014, 07:26:38 PM
In the bowels of theme_info.xml, you can define <based-on>. If used during installation, this will look up the theme_dir, theme_url and images_dir of the theme in question and make those available.

Could just be why I couldn't make it work? (None of my themes had 'based-on' specified till after they were installed and in use.)

Marking this topic as 'solved' because it seems I have the power and it's expected (?) on this board when my original question's been answered, but hope to see the interesting discussion continuing!

Peter Duggan

Quote from: Peter Duggan on January 24, 2015, 04:13:50 PM
If I want to change theme to utilise a single different template (let's call this 'Theme A') for a couple of boards

Possibly related question but, if not, please tell me where to ask...

The two boards (two 'sub-themes' if you like) with some different templates don't keep the header shrunk if you've shrunk it (whole forum still uses Curve-style shrinking/expanding header) when you leave them and come back, so any ideas what I need to look for or do to sort that?

Peter Duggan

Quote from: Peter Duggan on January 26, 2015, 08:23:25 PM
don't keep the header shrunk

When logged in! (Fine as guest.)

Quote
when you leave them and come back

Or refresh the page/go to another on that board.

Kindred

hmmmm... after 10 years I am still finding out new little gems about the system ...   lol
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Antechinus

It's amazing what's hidden in the bowels of SMF. Sometimes it's good, sometimes it aint. :D

Bloc

Well, its not the first time I've found gems...but thats whats happen when very few take any interest in a particular aspect fo SMF. I suspect this feature is of little use for regular admins, more perhaps for designers that like to build a foundation theme. But how many will do that - present company exluded? :)

And the bigger question: are anyone the slighest interested in anyone working on it? A rhetorical question(for me), because I already know the answer lol. Hence it will stay a "gem" and not a actively used feature. It might even be discarded in future versions since life goes on..and so on.

Suki

I actually borked this while working on 2.1 theme's stuff.  To be honest I left it broken because there was no one who ever used this feature, anyway, now that this hidden stuff was discovered I suppose I need to fix it :P
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: