Yogesh's Blog

Sharing me with blog…
Archive for the ‘Liferay’ Category

Liferay by default persist information of portlet mode for page in user session level. When same user navigates again the page, persisted mode is used and rendered. For example, Page1 have portlet1, portlet2 and portlet3. Page2 have portlet2, portlet3 and portlet4. If user is on Page1 and opens portlet2 in help mode, this combination of page and portlet mode is persisted by Liferay in user session level. If user then navigates to Page2 and comes back to Page1 then he gets portlet2 in help mode by default because he opened its help mode. Persistance of this is by default only taken care for Page and PortletMode. But not WindowState. If you like Liferay to persist portlet WindowState in case of┬ámaximised state, there is just a simple way. To inditate Liferay to persist maximized WindowState of portlet, turn on a property in portal-ext.properties. layout.remember.maximized.window.state=true Bydefault its value is false. Now liferay will persist WindowMode as well ­čÖé !  

Many times, there is need to know if current page is home page of site or not in liferay theme. For example, to hide breadcrumb for home page or to show special carousel on home page etc. In liferay, generally we just drag a page to first child in pages section of control panel to make a page as default page, which usually opens without any friendly url. There are couple of ways to identify a page as default page or home page. Option 1 : Comparing plid We can add following statement in vm file to know if current page is home page or not. #set ($isHomePage = $layout.getPlid()==$theme_display.getScopeGroup().getDefaultPublicPlid()) In this, $isHomePage variable will contain true if current page is default home page of site.   Option 2 : By using specific home page layout Many time, we create specific layout for home page. To know about home page, we can identify by current page’s layout to know if it is home page or not. Following statement can help in this. #set ($isHomePage = $layout.getTypeSettingsProperty(“layout-template-id”).equals(“homelayout-column-3-1”)) Here homelayout-column-3-1 is the id of layout we created for home page only. We declare this id in liferay-layout-templates.xml file of layout plugin.