Posts

Showing posts with the label Layout

Knowing About the layout

We can Check the page whether it is private or public page using layout object. layout.isPrivateLayout() layout.isPublicLayout() layout is an implict object in liferay By using this "layout" object we can get title , description, theme applied to that page, group, Also we can get the child page and parent page details. Forming the dynamic URL PortalUtil.getPathFriendlyURLPublic() : It retrieves "/web" PortalUtil.getPathFriendlyURLPrivateGroup() : It retrieves "/group" themeDisplay.getScopeGroup().getFriendlyURL(): It retrieves site name(ex: guest) So finally we can write as, If we want Public Page URL: PortalUtil.getPathFriendlyURLPublic()+ themeDisplay.getScopeGroup().getFriendlyURL() +StringPool.SLASH + "home"; It will be as "/web/guest/home. Also If we want Private Page URL: PortalUtil.getPathFriendlyURLPrivateGroup()+ themeDisplay.getScopeGroup().getFriendlyURL() + StringPool.SLASH...

Applying the theme , layout and setting the portlets for the Page template programmatically

In previous post we have seen adding the site template and page template programatically . If you want to look into those posts again please follow the links below. Creation of Site Template http://liferaytutorial.blogspot.in/2015/03/adding-site-template-programmatically.html Creation of Page Template http://liferaytutorial.blogspot.in/2015/03/adding-page-template-in-liferay.html Sometimes it required to add the portlet to layout and apply theme programatically. So here is the code, Here we are applying the 2 column layout with 1st column as " MessageBoard (19)" and 2nd column as " Search (3)" and " Blog (33)" portlets Also applying the theme "label_WAR_labeltheme. // Updating the column and Portlets for the pagetemplate LayoutPrototype layoutPrototype = LayoutPrototypeLocalServiceUtil.getLayoutProtoType(10011l); Layout layout = layoutPrototype.getLayout(); LayoutTypePortlet layoutTypePortlet =(LayoutTypePortlet)layout.getL...

Adding Page Template in liferay Programmatically

We know that we can create the page template from the control panel, What if we want to create programmatically. So here we go, 1. We are reterving the page template name form the portlet.properties. If you want to know how to create the portlet.properties and retrieve follow the below link. http://liferaytutorial.blogspot.in/2013/03/how-to-read-values-from-properties-file.html So here i am retrieving the page template name as page.template from portlet.properties file. String pageTemplateNames = PortletProps.get("page.template"); In Portlet. properties page.template = Home,Test Before adding the page template we are checking weather page template exists or not by dynamicQuery , because we don't have any finder method to check the page template by name. Here i am checking by descrition beacause name will be storing as JSON format in DB. List<LayoutPrototype> layoutProtoTypeList = null; DynamicQuery dynamicQuery = DynamicQueryFactoryUti...

Adding Site Template Programmatically

We know that we can create the site template from the control panel, What if we want to create programmatically. So here we go, 1. We are reterving the site template name form the portlet.properties. If you want to know how to create the portlet.properties and reterive follow the below link. http://liferaytutorial.blogspot.in/2013/03/how-to-read-values-from-properties-file.html So here i am reterving the site name as  site.template from portlet.properties file. String siteTemplateNames = PortletProps.get("site.template"); In portlet.properties site.template = SiteTemplate1 , SiteTemplate2 Before adding the site template we are checking weather site template exists for not by dynamicQuery , because we don't have any finder method to check the site template by name. Here i am checking by descrition beacause name will be storing as JSON format in DB. DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(LayoutSetPrototype.class); dynamicQuery....