Creating child theme for OMP

Hi,

I’m trying to create child theme for OMP. Already did that for OJS and it’s working fine there, but i have a problem with OMP. Everything is the same as in OJS, but on plugins OMP page i get infinitive loading animation. In the error log i have:

PHP Fatal error: Uncaught Error: Call to a member function getCurrent() on null in /omp/lib/pkp/classes/site/VersionDAO.inc.php:103\nStack trace:\n#0 /omp/lib/pkp/classes/controllers/grid/plugins/PluginGridHandler.inc.php(184): VersionDAO->insertVersion(NULL, true)\n#1 /omp/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(124): PluginGridHandler->loadCategoryData(Object(Request), ‘themes’, Array)\n#2 /omp/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(473): CategoryGridHandler->getGridCategoryDataElements(Object(Request), ‘themes’)\n#3 /omp/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(453): CategoryGridHandler->_renderCategoryInternally(Object(Request), Object(PluginCategoryGridRow))\n#4 /omp/lib/pkp/classes/controllers/grid/CategoryGridHandler.inc.php(276): CategoryGridHandler->_renderCategoriesInternally(Object(Request))\n#5 /omp/lib/pkp/classes/controllers/grid/GridHandler.inc.php(643): CategoryGrid in /omp/lib/pkp/classes/site/VersionDAO.inc.php on line 103

This is what i have in index.php

require_once('ChildThemePlugin.inc.php');
return new ChildThemePlugin();

and this is ChildThemePlugin.inc.php

import('lib.pkp.classes.plugins.ThemePlugin');

class ChildThemePlugin extends ThemePlugin {

        public function init() {
                $this->setParent('defaultthemeplugin');
        }

        function getDisplayName() {
                return 'My Theme';
        }

        function getDescription() {
                return 'Some description...';
        }
}

Anyone have an idea what could be wrong? Thx.

Regards.

Hi @orcalator

It’s been a while since I’ve looked at building an OMP plugin, but that line of code is expecting a Version object, and it’s getting null instead. This might be due to the fact that your plugin is present on disk but not actually installed, so there is no version history for it yet. I see similar things when building plugins on disk and then test loading them. It’s unusual to have a plugin on disk but not have it in the database also. Normally the database record is created when you upload the .tar.gz via the plugin grid.

You can install a plugin via:

php lib/pkp/tools/installPluginVersion.php plugins/path/to/plugin/version.xml

Best
Jason

@jnugent,

I solved it by installing OMP again. All is fine now. Thank you for help.


Thank you for help. I tried it but i get this:

php lib/pkp/tools/installPluginVersion.php ./plugins/themes/child/version.xml

PHP Fatal error:  Uncaught Error: Call to a member function getName() on int in /omp/lib/pkp/tools/installPluginVersion.php:71
Stack trace:
#0 /omp/lib/pkp/tools/installPluginVersion.php(99): InstallPluginVersionTool->execute()
#1 {main}
  thrown in /omp/lib/pkp/tools/installPluginVersion.php on line 71

@jnugent,

Unfortunately i have another problem now. Child theme is installed but it seems OMP is still showing up default theme on frontend. I want to change 2 templates and i made the same file structure as in OJS:

/templates/frontend/pages/indexSite.tpl
/templates/frontend/components/header.tpl (filename here is different then in OJS - headerSite.tpl in OJS)

However, whatever change i make to templates, default OMP template is shown. I tried clearing template cache but it didn’t work. Any ideas? Thx.

Regards.

Hi @orcalator

My understanding is that the indexSite.tpl template is only loaded outside of a journal context. Is your theme installed at the site level?

Best
Jason

Hi @jnugent,

Yes, it is installed on a site level and this works in OJS although my custom child theme is not checked under the “Theme plugins” (also a bit strange). Only theme that is checked is “Default theme”. However in OMP it doesn’t work (checked or unchecked).

Regards.

Ok, i solved it. I just had to choose “My theme” from “Appearance” menu. All fine now!