Hi, I’m working on Liferay DXP 7.3 with a custom theme deployed. I need to include scripts and CSS in the head tag of the theme dynamically, as the source changes frequently. What are the possible ways to do this?
Looking at portal_normal.ftl, there is an extension point already, which you can utilize and calculate whatever you need:
<@liferay_util["include"] page=top_head_include />
It points to here, which points to here. And there you find the best maintainable way to extend it:
<liferay-util:dynamic-include key=“/html/common/themes/top_head.jsp#pre” />
A DynamicInclude. Encapsulate your logic there and calculate whatever you want to add to the head section without modifying any existing or other custom file. It’ll all be well encapsulated in that single component.
Thank you, Olaf. It works perfectly.