在第四篇《Liferay Portal额外研究(4):修改用户登录后的默认布局和内容》中,我讲了修改用户登录首页布局的方案,此篇再给提供一种更简洁的处理方案。
在第四篇的方案,其实有些违背Liferay的扩展本意,Liferay提供了在外围配置的方式,来统一设置用户的第一次默认登陆首页。
在portal_ext.properties中通过修改相应参数来控制:
# Set the layout name.
default .user.layout.name = Home
# Set the layout template id that matches an existing TPL.
default .user.layout.template.id = 2_columns_ii
# Set the layout ids for the column specified in the layout template.
default .user.layout.column - 1 = 82 , 23 , 61 , 65 ,
default .user.layout.column - 2 = 8 , 11 , 36 , 33 ,
default .user.layout.column - 3 =
default .user.layout.column - 4 =
# Enter either " 800x600 " or " 1024x768 " to set the layout resolution.
default .user.layout.resolution = 80 0x600
default .user.layout.name = Home
# Set the layout template id that matches an existing TPL.
default .user.layout.template.id = 2_columns_ii
# Set the layout ids for the column specified in the layout template.
default .user.layout.column - 1 = 82 , 23 , 61 , 65 ,
default .user.layout.column - 2 = 8 , 11 , 36 , 33 ,
default .user.layout.column - 3 =
default .user.layout.column - 4 =
# Enter either " 800x600 " or " 1024x768 " to set the layout resolution.
default .user.layout.resolution = 80 0x600
可以通过修改“default.user.layout.template.id”属性来控制页面的布局格式;通过修改“default.user.layout.column-X”的属性来控制不同列防止的portlet。
但如果为了更加符合一些商业性的需求,比如同一个Location的下的user默认布局相同,等等,这些则需要重载ServicePreAction类,重载 addDefaultLayouts 方法来实现,然后再在portal_ext.properties修改相应属性即可。
servlet.service.events.pre=com.liferay.portal.events.ServicePreAction