Child theme override not working, no errors

Hi folk!

I am working on building our local theme into OJS 3 and I decided to go with the child theme route as that seems a lot cleaner. However, I’m running into a disconnect between what the docs say and what’s actually happening and was wondering if you all might have any ideas?

My init is doing the following two steps:
$this->setParent(‘defaultthemeplugin’);
$this->modifyStyle(‘stylesheet’, array(‘addLess’ => array(‘styles/chass_variables.less’)));

chass_variables.less is a full copy of the variables.less file from default/styles where I have modified a few fields – basically just the font and some background colors just to test to make sure it works. (like I was aiming to make the background color something ridiculous for testing purposes) However, my modifications are not coming through at all. All I’m getting is the default theme’s colors so it’s as of mine are being flat out ignored.

I am running PHP 5.6.30 and I do see a long myriad of PHP Strict Standards warnings and PHP Deprecated warnings from within the OJS 3 code, but no errors or warnings beyond that. Nothing about being unable to build compile the less file or anything. I actually installed the less compiler and compiled it manually just to make sure it didn’t throw errors.

Any ideas what I might be missing or where I should be looking? From my perspective I’ve done exactly what the demonstration and documentation suggests. =/

Note: template files and explicitly included css files are working, it’s just the less based override that is not.

Thanks!

Hi @Daniel_Henninger,

Tagging @NateWr, who is the best resource for this (though he’s away for a few days).

One suggestion: Make sure your plugin is registered with the system. When you install a plugin, it creates an entry in the versions table; when you write one from scratch you haven’t gone through any registration process so that entry might not exist.

You could either create it manually in the database (following other examples), or run the upgrade script (php tools/upgrade.php upgrade) to register all plugins with the system. Make sure you back up before you run the upgrade script. Also ensure that the plugin’s version.xml descriptor is correct.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec! Thankfully it was indeed already registered, but I did bump the version and run the upgrade script “just in case” and I’m afraid it did not change anything. =(

Just to make sure, this should be correct?

chass
plugins.themes
4.0.0.1
2017-04-13
0
CHASSThemePlugin

4 0 0 1 is what it shows in the versions table, CHASSThemePlugin.inc.php exists, and is doing the above steps?

Also index.php contains (trimming comments and such):
require_once(‘CHASSThemePlugin.inc.php’);

return new CHASSThemePlugin();

And no worries re: Nate! =) Thanks!

Hi @Daniel_Henninger,

The important things to check are…

  • The product_class_name column must match the PHP classname of your theme plugin
  • The product column must match the name of the directory you’ve placed it in (in this case, in themes since it’s a theme plugin)
  • The product_type must be correct for your plugin category – in this case, plugins.themes

If those aren’t correct, typical behavior would be to see your plugin getting loaded e.g. in the plugin administration area, but not other places.

Other details, such as version numbers, aren’t important here.

Regards,
Alec Smecher
Public Knowledge Project Team

Ah! Ok I’ve confirmed all of those are correct:
product_type: plugins.themes
product: chass
product_class_name: CHASSThemePlugin

I -did-, however, notice that the previous version did not have product_class_name set so perhaps that was part of my woes! =) I’m going to try clearing some caches now that I’ve “upgraded” and see if that changes anything.

Interesting. Ok so, clearing the template and data cache didn’t seem to accomplish anything.
However, I then went to the journal settings and re-chose my theme and just on a whim messed with the color selector and low and behold it’s loading my style!

Now, afterwards I went in and adjusted the .less file yet again and it didn’t take. So I went back to the journal settings and just saved it as-is and that triggered the style change to work.

So I’m guessing something is getting cached somewhere that clear template cache is not catching perhaps? Either way, hitting save on the journal settings seems to be doing the trick so I am good to go! =) Thanks!!

Hi @Daniel_Henninger,

That sounds like progress. You should see .css files showing up the cache/ directory – clearing these will cause the .less files to get re-compiled.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Awesome thanks! That will save me some time. =)

1 Like

Hi!

I’m trying to configure a bootstrap3 child theme. I already have a bootstrap3 theme working, but when I install the child theme it appears on the pluggin section but doesn’t apear on the appearence configuration.

Do you have ant tip to help me, please? I’m just a begginer. Thanks,

Hi @lux666,

What OJS version you are using? Can you double-check if the theme is activated for the specific journal that you are working with (not only site-wide)? Are there any associated errors in the PHP logs? It should be something that points to the problems in the code.

Also, you may encounter this bug when working with themes that don’t directly extend the Default. It’s not related to you current problem but you won’t be able to override templates. If the modification of templates is not the aim, you can ignore this. The fix will be shipped in the next release but you can apply these changes to the code: https://github.com/pkp/pkp-lib/pull/5126/commits/0da73c3f7263acf3e0dd433c0646d2cc674ad4ac

Hi! Thanks for the answer! OJS 3.1.2.1.

hey, @Vitaliy I was trying to use a child theme with bootstrap3 as father and the child theme said to me that “He is not his father” XD. So I asked to a another friend to let me see his OJS configuration and I discovered that he is using Bootstrap3 as Theme but he hasn’t a child theme. So the million-dollar question is: Does exist a bootstrap3 child theme for OJS?

By now our family is ok, with default theme & default theme child, but I love bootstrap3, it’s so clear and minimalist! Thanks for your help!:metal:

Hi @lux666,

I haven’t seen examples of the child of the Bootstrap3 theme. But it can be developed using guidelines.