留言板
How to get user's private page url
Hi,
How can we get user's private page url?
Like, if we need user's public home page then we can use user.getDisplayURL(themeDisplay).
Do we have any such method for getting user's private page url ?
How can we get user's private page url?
Like, if we need user's public home page then we can use user.getDisplayURL(themeDisplay).
Do we have any such method for getting user's private page url ?
If you are looking to get the private url only when user is existed on that page.....So,you can achieve it through themeDisplay.getURLCurrent() i hope.Correct me if you thinking of other scenario.
Sandeep Nair,修改在12 年前。
RE: How to get user's private page url
Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子Tejas Kanani:
Hi,
How can we get user's private page url?
Like, if we need user's public home page then we can use user.getDisplayURL(themeDisplay).
Do we have any such method for getting user's private page url ?
Hi Tejas,
If you see UserImpl where this getDisplayURL is implemented the logic is written for fetching the public page
public String getDisplayURL(String portalURL, String mainPath)
throws PortalException, SystemException {
if (isDefaultUser()) {
return StringPool.BLANK;
}
Group group = getGroup();
int publicLayoutsPageCount = group.getPublicLayoutsPageCount();
if (publicLayoutsPageCount > 0) {
StringBundler sb = new StringBundler(5);
sb.append(portalURL);
sb.append(mainPath);
sb.append("/my_places/view?groupId=");
sb.append(group.getGroupId());
sb.append("&privateLayout=0");
return sb.toString();
}
return StringPool.BLANK;
}
Just do the same for private ones. by passing privateLayout=1 and checking the condition privateLayoutsPageCount>0
Regards,
Sandeep
Tejas Kanani,修改在12 年前。
RE: How to get user's private page url
Liferay Master 帖子: 654 加入日期: 09-1-6 最近的帖子
Thanks Sandeep.
Its exactly same what I am looking for.
Its exactly same what I am looking for.
Hi,
I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
I used this in a post login hook where ThemeDisplay isn't available.
I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
public void run(HttpServletRequest request, HttpServletResponse response)
throws ActionException {
String path = "";
// attempt to get path to User private page
User user = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request));
// check for private layouts
if (LayoutLocalServiceUtil.hasLayouts(user, true)) {
List<layout> layouts = LayoutLocalServiceUtil.getLayouts(user.getGroupId(), true);
if (layouts.size()>1){
_log.info("More then 1 private layout found for User while max. 1 is assumed. The last layout is returned.");
}
for (Layout layout : layouts) {
path = PortalUtil.getLayoutActualURL(layout);
}
}
if (Validator.isNotNull(path)) {
LastPath lastPath = new LastPath(StringPool.BLANK, path,new HashMap<string, string[]>());
HttpSession session = request.getSession();
session.setAttribute(WebKeys.LAST_PATH, lastPath);
}
}
</string,></layout>
I used this in a post login hook where ThemeDisplay isn't available.
Juan Fernández,修改在11 年前。
RE: How to get user's private page url
Liferay Legend 帖子: 1261 加入日期: 08-10-2 最近的帖子
sachin maheshwari,修改在10 年前。
RE: How to get user's private page url
Junior Member 帖子: 52 加入日期: 10-12-4 最近的帖子
This is the one i am looking for sort and simple.