Reputation: 573
I am currently using liferay 6.1. I want to access portal-ext.properties in liferay-portlet.xml file. Is there any way to access it? I want replace version from ext properties dynamically.
liferay-portlet.xml
<header-portlet-css>/css/main.css?v={version}</header-portlet-css>
portal-ext.properties code
version=3
Upvotes: 1
Views: 872
Reputation: 9022
It's not possible out of the box - if you check PortletLocalServiceImpl._readLiferayPortletXML
you will see: there is no property interpolation.
And if you check PortalImpl.getStaticResourceURL
you will see: a ?
in the URI of a CSS file will even drop all other generated parameters (like timestamp of last modification):
if (uri.indexOf(CharPool.QUESTION) != -1) {
return uri;
}
So it was never intended to have any query parameters in the CSS URIs of a portlet.
If you really need the property, you can either change your build process to interpolate the version attribute during build time.
Or you create a Hook or Ext Plugin that overrides PortalImpl.getStaticResourceURL
and does the interpolation for you. That is the more complex but better option, as it could add the Liferay specific parameters as well.
But, if you just want to increase a version flag to ensure that the file is not cached if you change something: There is no need to do that. If you add no question mark, like
<header-portlet-css>/css/main.css</header-portlet-css>
than Liferay will add a timestamp parameter automatically:
.../css/main.css?...&t=1234567
where 123456
is the modification time of your main.css
. If you include some other files in the main.css
, then you simply need to "touch" the main.css
every time you change one of the other files.
Upvotes: 2