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())
$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"))
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.