Posts

Liferay DXP upgrading classic theme to Client extension

Image
Migrating legacy Liferay WAR-based themes to modern Theme CSS Client Extensions decouples your styling from the core runtime, eliminating OSGi dependency issues and enabling zero-downtime deployments. This guide covers how to set up your configuration and restructure your project files for the upgrade. Breakdown the Traditional Theme Components Before writing code, analyze your legacy theme assets and map them to Liferay 7.4 equivalents: portal_normal.ftl (Structure): Migrates to Liferay Master Pages or Page Templates using the UI editor. custom.css / SCSS (Styles): Migrates to a Theme CSS Client Extension . favicon.ico: Migrates to a Theme Favicon Client Extension . Theme SVG Spritemaps: Migrates to a Theme Sprite Map Client Extension . Migrating to a Theme CSS Client Extension: The theme CSS client extension is available in Sample client extension for your reference. 1. Understanding client-extension.yaml The client-extension.yaml file co...

Liferay migration to version 7.x

This blog explains the process of upgrading the Liferay core installation to version 7.0 in simple steps. Note : If you are doing migration from 6.1 and earlier, go through the following link  Upgrade to Liferay 7  and proceed with the following steps. Step 1 Install jdk 8 and mysql 5.7 in your system. Please refer this compatibility matrix for version details  Compatibility Matrix PDF . Step 2  Take backup of your existing Liferay installation and Database that you are about to migrate. Step 3 Install Liferay 7 in your system. Update the 'portal-ext.properties' by pointing out the existing database (i.e earlier version). Dont start it. If you start it, you will get error message as follows: You must first upgrade to Liferay Portal 7000 Step 4 Copy and paste existing  [Liferay Home]/data/document_library folder in to new installation. For more details about Document Management , follow this  document-repository-configuration Step ...

Embed portlet in liferay 7 FTL theme

To include portlet in liferay 7 ftl theme , use the code as follows. <@liferay_portlet["runtime"] defaultPreferences="${freeMarkerPortletPreferences}" portletProviderAction=portletProviderAction.VIEW instanceId="blablabla1" portletName="com_liferay_site_navigation_directory_web_portlet_SitesDirectoryPortlet" /> where , instanceId="blablabla1" have to be given only for instanceable portlet, "com_liferay_site_navigation_directory_web_portlet_SitesDirectoryPortlet" is portletId.

Creating PortletURL in Javascript

At times, we are supposed to create PortletURL in Javascript. We can do like this as follows. <aui:script use = "liferay-util-window,liferay-portlet-url" > var portletURL = Liferay.PortletURL.createRenderURL(); portletURL.setPortletId(' <%= PortletKeys . SOME_PORTLET %>'); portletURL.setPlid(15932); portletURL.setWindowState(' <%= LiferayWindowState . POP_UP . toString () %>'); portletURL.setParameter('param1', param1); portletURL.setParameter('param2', param2); portletURL.setParameter('mvcPath', '/html/my_portlet/my_page.jsp'); // Now we can use the URL console.log(portletURL.toString()); </aui:script> Similarly you can also create other URL type as needed: Liferay.PortletURL.createActionURL() Liferay.PortletURL.createPermissionURL() Liferay.PortletURL.createResourceURL() Liferay.PortletURL.createURL()

Liferay 7 overriding MVC Commands

MVCActionCommand : An interface that allows the portlet to process a particular action request. By extending  BaseMVCActionCommand , we can customize processAction method. MVCRenderCommand : An interface that handles the render phase of the portlet. By   extending  BaseMVCRenderCommand , we can customize render method. MVCResourceCommand : An interface that allows the portlet to serve a resource. By  extending  BaseMVCResourceCommand , we can customize serveResource method. Now , we will see how to customize processAction method. Step 1: Initially, Create one module as mentioned in Liferay 7 document. Step 2: In controller class, write the component property depends on which modules you are customizing, for eg., if we customize create account page, write as following @Component( property = { "javax.portlet.name=com_liferay_login_web_portlet_FastLoginPortlet", "javax.portlet.name=com_liferay_l...

Liferay Popups

1. Displaying content as pop up <script> function showDependancyPopup() {               var content = $('#id').html();         AUI().use('aui-base', 'aui-io-plugin-deprecated',                 'liferay-util-window', function(A) {                     var popUpWindow = Liferay.Util.Window.getWindow({                         dialog : {                             centered : true,                             constrain2view : true,       ...

Set page permissions to role programmatically

In JSP, // getting list of all public pages List<Layout> pageList = LayoutLocalServiceUtil.getLayouts(themeDisplay.getScopeGroupId(), false); for(Layout pages : pageList){ <input type="checkbox" name='<portlet:namespace/>page' value="<%=pages.getPlid() %>" <%=checked%> /><%=pages.getName() %><%=pages.getPlid()  %> } In Controller, String[] pages = ParamUtil.getParameterValues(request, "page");   for(String page : pages){  long plId = Long.parseLong(page); Layout layout = null; try { layout = LayoutLocalServiceUtil.getLayout(plId); } catch (SystemException e) { }    ResourcePermissionServiceUtil.setIndividualResourcePermissions(themeDisplay.getScopeGroupId(),    themeDisplay.getCompanyId(), Layout.class.getName(), String.valueOf(layout.getPrimaryKey()),    role.getRoleId(), new String[] { ActionKeys.VIEW }); }