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.

Bloc

The sensible thing would be to remove it. Unused features are just that: unused.

Suki

Completely removing its actually a lot more difficult and will break some other related things if it doesn't get properly done. Way more easier to just re-add the old stuff maybe update the code a bit but thats about it.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Peter Duggan

Quote from: Peter Duggan on January 26, 2015, 08:23:25 PM
The two boards (two 'sub-themes' if you like) with some different templates don't keep the header shrunk if you've shrunk it

So anyone got the foggiest about this?

Forum's at www.polldubhclub.org/forum/, but it's only happening when you're logged in (can supply a test account if a team member wants to take a look). The main reason for the sub-themes was to add some in-your-face posting reminders to the Logbook and Home Page Content boards + Calendar (but nothing you can see without being in the groups permitted to post to them) because they're now feeding content to our home page via SSI.php, but I might yet take at least the 'logbook' theme further and develop it to look like, well, more of a logbook! There are also nice wee links you can't see to take those with the requisite permissions straight from the home page 'SSI' sections ('quick news', 'upcoming calendar', 'latest logbook entries' and other 'what's happening?' stuff) to the relevant SMF posting forms, but that's irrelevant to the won't-stay-shrunk header issue.

Theme directories currently contain...

polldubh (forum default):
BoardIndex.template.php
Calendar.template.php
index.php (same as default's)
index.template.php
ManageNews.template.php
Stats.template.php
theme_info.xml
------------------------------------------------------------
index.css
rtl.css (same as default's)
------------------------------------------------------------
backdrop.png
end_cap.png (to give 'Curve' true rounded corners over fixed page background image)
frame_repeat.png
loadingbar.png (same as default's)
main_block.png
menu_gfx.png
quickbuttons.png (same as default's)
quote.png (same as default's)
submit_bg.png (same as default's)
------------------------------------------------------------
Admin.english.php
index.english.php
index.english.php~
PersonalMessage.english.php
------------------------------------------------------------
theme.js (same as default's)

polldubh_content:
BoardIndex.template.php (same as polldubh's)
GenericControls.template.php
index.php (same as polldubh's)
index.template.php (same as polldubh's)
Post.template.php
Stats.template.php (same as polldubh's)
theme_info.xml
------------------------------------------------------------
index.css (same as polldubh's)
rtl.css (same as polldubh's)
------------------------------------------------------------
index.english.php
index.english.php~
PersonalMessage.english.php (same as polldubh's)
------------------------------------------------------------
theme.js (same as polldubh's)

polldubh_logbook:
BoardIndex.template.php (same as polldubh's)
index.php (same as polldubh's)
index.template.php (same as polldubh's)
Post.template.php
Stats.template.php (same as polldubh's)
theme_info.xml
------------------------------------------------------------
index.css (same as polldubh's)
rtl.css (same as polldubh's)
------------------------------------------------------------
index.english.php
index.english.php~
PersonalMessage.english.php (same as polldubh's)
------------------------------------------------------------
theme.js (same as polldubh's)

images directories are all set to default (Curve), with backgrounds pulled from polldubh/images by index.css.

So of course most of this is irrelevant to the header not staying shrunk (surely a JavaScript issue?), but just trying to provide as much info as possible in case I've missed something!

Mimmi

I feel like this should be my solution :D , but I can't really grasp it. Could you please advise me to whether I should be able to achieve my goal through the use of based-on-tag?

I have a forum with 3 sections and each section should have different user-rights and their own color.:

  • family – red
  • friends – purple
  • acquaintances – blue
The different colors are there to make sure the users know what part of the forum they're in. "This is blue. If I write anything here, everyone will see it."

I have bought a blue theme, with a red version in the package: StickUp. Can the blue theme be the "mother-theme" and a red and a purple versions be "child themes"?

If I have understood the based-on-feature right, I could make a theme folder called StickUpRed with only two contents:

  • theme_info.xml
  • css/red.css

Then the red.css will override some of the css in the mother theme, but the rest of the css and the templates etc will be taken from the mother theme: StickUp

Is this right? Will SMF first get the stuff it need from the child theme StickUpRed, and the stuff it needs that are not in that folder, it will get from the mother theme in the folder StickUp?

I cannot get it to work, so I'm afraid I misunderstood the use of based-on.
Forum-junkie and still a newbie in the world of administrating php etc... Volunteers in reproductive rights. http://www.liv-laga.no/

Advertisement: