Skip to main content
Topic: Theme.php inside default theme (Read 2866 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Theme.php inside default theme

Is it supposed to be something custom themes can change? Whats the idea behind putting it there?

Re: Theme.php inside default theme

Reply #1

I guess you are talking about 1.1, in that case, if @Joshua Dickerson passes by is the best person to explain. :P
Bugs creator.
Features destroyer.
Template killer.

Re: Theme.php inside default theme

Reply #2

Yes, 1.1 :)

I see there are a lot of changes in it, many OOP related. Also realized the script actually checks if Theme.php exists in a custom theme - so that means it can in fact be changed.  :D 

Re: Theme.php inside default theme

Reply #3

I am puzzled..there are quite a lot of power there..I mean, the loading functions for CSS files, and even menu context setup lol. While I welcome the latter because I am not so thrilled about having code for avatar right inside the profile menu link - which I had to remove by CSS, now I can just adjust Theme.php.

Re: Theme.php inside default theme

Reply #4

TBH, I'm not yet really that convinced about Theme.php in the theme. And the fact it delegates the menu structure to the theme is one of the reasons (plus 8 or 9 methods that, to me, do not belong to the theme in any way), but okay.

The avatar in the menu is added by CSS, one line of css (albeit with an "!important") is usually easier than have to replace the entire file just for that. ;)
But that's just the way I would do it. :P
Bugs creator.
Features destroyer.
Template killer.

Re: Theme.php inside default theme

Reply #5

Oh I am not having difficulty doing it CSS-wise - but building a default theme too rigid, too dependent on preset structures will only encourage color versions of said theme. SMF's been doing it for years, and sadly enough I never convinced anyone to change this lol.

Anyways, its not something I wish to impose om Elkarte either, you guys have a working theme you can build on - but this Theme.php actually seem to lend me much more freedom. Not just exchanging one link, surely, if its any point to use it there has to be enough changes to warrant a full exchange of the file. Most theme makers might not even consider changing it. Thats why I am curious about the intended usage of it.

Re: Theme.php inside default theme

Reply #6

How to extend this (properly) and make it your own:

The relevant code to change is
Code: [Select]
namespace Themes\DefaultTheme;

/**
 * Class Theme
 *
 * - Extends the abstract theme class
 *
 * @package Themes\DefaultTheme
 */
class Theme extends \Theme
Change DefaultTheme to your preferred namespace.

For your need,  it goes like this
Code: [Select]
namespace Themes\Orion;

/**
 * Class Theme
 *
 * - Extends the abstract theme class
 *
 * @package Themes\Orion
 */
class Theme extends \Themes\DefaultTheme

Wanna include your handle? Replace Themes\Orion with Themes\Bloc\Orion
(only use backslashes here)

Now the  fun stuff. Remove everything you don't want. All public, unlabeled, and protected methods (functions) can be overridden. Anything labeled private is no longer available.

Methods that may be overridden
Code: [Select]
Theme.php:37: public function template_rawdata()
Theme.php:47: public function template_header()
Theme.php:112: protected function headerSent($type)
Theme.php:129: public function theme_copyright()
Theme.php:149: public function template_footer()
Theme.php:178: protected function templateJquery()
Theme.php:226: protected function templateJavascriptFiles($do_deferred)
Theme.php:279: function template_javascript($do_deferred = false)
Theme.php:346: function template_css()
Theme.php:385: function template_inlinecss()
Theme.php:421: function template_admin_warning_above()
Theme.php:461: public function addCodePrettify()
Theme.php:480: public function autoEmbedVideo()
Theme.php:504: public function doScheduledSendMail()
Theme.php:541: public function relativeTimes()
Theme.php:576: function setupThemeContext($forceload = false)
Theme.php:771: public function setupMenuContext()
Theme.php:1205: public function loadThemeJavascript()
Theme.php:1254: public function loadDefaultLayers()
Theme.php:1325: public function loadThemeVariant()

This is all code theory based on reading the code and is therefore untested.
LiveGallery - Simple gallery addon for ElkArte

Re: Theme.php inside default theme

Reply #7

That's exactly the idea.