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.getLayoutType();
layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(),"2_columns_iii");
layoutTypePortlet.setTypeSettingsProperty("column-1","19");
layoutTypePortlet.setTypeSettingsProperty("column-2","3,33");
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),true,layout.getLayoutId(),layout.getTypeSettings());


LayoutLocalServiceUtil.updateLookAndFeel(layout.getGroupId(), true, layout.getLayoutId(), "label_WAR_labeltheme",
"01", "", false); // Updating the theme for the pagetemplate



Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate