Friday, August 18, 2017

How to Access Liferay Services in Velocity(VM) files using Service Locator?


Some time we need to access Liferay Services in our theme or Web content Templates. So today we will discuss how to access Liferay Services in our theme and templates. 

For Theme
If you want to access liferay services like user services in your theme you can use this code in portal_normal.vm:-



Explanation:-
Here we first get the UserLocalService object and then call getUsersCount method.







For Web Content Templates
You can use the above code in your templates files but you need to do one extra step. Just enter :-

velocity.engine.restricted.variables=

in your portal-ext.properties and restart server.




No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!