Reputation: 3386
Can anyone please tell me how to dynamically change page layout in Liferay. Let's consider we have page with Layout 2 column(50/50) and both these columns have portlets. If a user clicks on any of the portlets, I Would like to change the page layout to 2 column(70/30).
Upvotes: 1
Views: 2174
Reputation: 8767
Below is a sample html portion from a layout template...
<div class="portlet-layout">
<div class="aui-w70 portlet-column portlet-column-first" id="column-2">
$processor.processColumn("column-2", "portlet-column-content portlet-column-content-first")
</div>
<div class="aui-w30 portlet-column portlet-column-last" id="column-3">
$processor.processColumn("column-3", "portlet-column-content portlet-column-content-last")
</div>
</div>
if you check it minutely, there are classes describing the width of the div, In my example aui-w70 is for width 70% and aui-w30 is for 30%. I am sure you will also get similar things in your layout too. If you can change the class names according to your need in desired events, you are good to go... Give it a try....
Upvotes: 0
Reputation: 139
Adding to- As provided-
layoutId = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, false, friendlyURL);
pass the new page's friendlyURL, if it is a public page then false else true for private, and make sure that you have applied some layout to the new page(for e.g- 70/30)
Use this layoutId in -
" windowState="<%= WindowState.NORMAL.toString()%>">
provide portletId to the portletname field.
Upvotes: 0
Reputation: 1798
I have never tried it but did you try checking LayoutLocalServiceUtil.updateLayout()
?
That should help you. If you are creating a new page use LayoutLocalServiceUtil.addLayout()
otherwise use updateLayout()
.
Get layout and then update it.
layout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, false, friendlyURL);
Upvotes: 1