5

我想获得一个基于布局 ID 的布局的友好 URL。例如,/web/group/page。目前我是这样做的:

Layout layout = LayoutLocalServiceUtil.getLayout(groupId, false, layoutId);

String groupFriendlyUrl = GroupLocalServiceUtil.getGroup(groupId).getFriendlyURL(); //will output /group
String layoutFriendlyUrl = layout.getFriendlyURL(); //will output /page
String webFriendlyUrl = String.format("/web%s%s", groupFriendlyUrl, layoutFriendlyUrl); //will output /web/group/page

我想知道是否有更好的方法可以做到这一点,我可以使用一种方法获得完整路径 /web/group/page 。

4

2 回答 2

4

如果您有plid(页面布局 ID),请使用getLayoutFriendlyURL()如下:

Layout selectedLayout = LayoutLocalServiceUtil.getLayout(plid);
String url = PortalUtil.getLayoutFriendlyURL(selectedLayout, themeDisplay);
于 2014-06-29T17:29:45.860 回答
1
  1. ThemeDisplay theme = (ThemeDisplay) getPortletRequest().getAttribute(WebKeys.THEME_DISPLAY);

  2. final long GROUP_ID = theme.getLayout().getGroupId(); Layout destinationLayout = LayoutLocalServiceUtil.getFriendlyURLLayout(GROUP_ID, false, friendlyUrl);

  3. Layout layout = LayoutLocalServiceUtil.getLayout(destinationLayout.getPlid()); String completeUrl = PortalUtil.getLayoutFullURL(layout, getThemeDisplay());

于 2015-04-29T09:38:51.583 回答