Search code examples
javaliferayliferay-themeliferay-7

Liferay DXP: adding java class to theme


Until now I have always provided my theme with some sort of NavigationUtil-Class written in Java and put under docroot\WEB-INF\src.

I upgraded my theme to Liferay DXP using the Theme Generator and blade cli. Now the java class does not seem to get registered as it used to in a normal sdk project.

Do I have to seperate it from the theme now or are there other ways to integrate java into theme?


Solution

  • After a few hours of research I stumbled upon Template Context Contributor, which can provide variables into the theming/templating context really easily.

    For anyone else who is interested, read this tutorial: https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/context-contributors

    Cheers!