Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Tejas Kanani
How to get user's private page url
September 27, 2011 11:32 PM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

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 ?
Anil Sunkari
RE: How to get user's private page url
September 27, 2011 11:56 PM
Answer

Anil Sunkari

Rank: Expert

Posts: 385

Join Date: August 11, 2009

Recent Posts

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
RE: How to get user's private page url
September 28, 2011 12:27 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1692

Join Date: November 5, 2008

Recent Posts

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

 1public String getDisplayURL(String portalURL, String mainPath)
 2        throws PortalException, SystemException {
 3
 4        if (isDefaultUser()) {
 5            return StringPool.BLANK;
 6        }
 7
 8        Group group = getGroup();
 9
10        int publicLayoutsPageCount = group.getPublicLayoutsPageCount();
11
12        if (publicLayoutsPageCount > 0) {
13            StringBundler sb = new StringBundler(5);
14
15            sb.append(portalURL);
16            sb.append(mainPath);
17            sb.append("/my_places/view?groupId=");
18            sb.append(group.getGroupId());
19            sb.append("&privateLayout=0");
20
21            return sb.toString();
22        }
23
24        return StringPool.BLANK;
25    }


Just do the same for private ones. by passing privateLayout=1 and checking the condition privateLayoutsPageCount>0

Regards,
Sandeep
Tejas Kanani
RE: How to get user's private page url
October 6, 2011 11:12 PM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Thanks Sandeep.

Its exactly same what I am looking for.
Cas Stigter
RE: How to get user's private page url
October 9, 2012 7:38 AM
Answer

Cas Stigter

Rank: New Member

Posts: 5

Join Date: June 28, 2011

Recent Posts

Hi,

I know you found a solution, I just wanted to add an example that doesn't use strings concatenation.
 1
 2    public void run(HttpServletRequest request, HttpServletResponse response)
 3            throws ActionException {
 4       
 5        String path = "";
 6        // attempt to get path to User private page
 7        User user = UserLocalServiceUtil.getUser(PortalUtil.getUserId(request));
 8        // check for private layouts
 9        if (LayoutLocalServiceUtil.hasLayouts(user, true)) {
10            List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(user.getGroupId(), true);
11            if (layouts.size()>1){
12                _log.info("More then 1 private layout found for User while max. 1 is assumed. The last layout is returned.");
13            }
14            for (Layout layout : layouts) {               
15                path = PortalUtil.getLayoutActualURL(layout);
16            }                  
17        }
18
19        if (Validator.isNotNull(path)) {
20            LastPath lastPath = new LastPath(StringPool.BLANK, path,new HashMap<String, String[]>());
21            HttpSession session = request.getSession();
22            session.setAttribute(WebKeys.LAST_PATH, lastPath);
23        }       
24    }


I used this in a post login hook where ThemeDisplay isn't available.
Juan Fernández
RE: How to get user's private page url
October 10, 2012 11:37 AM
Answer

Juan Fernández

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1246

Join Date: October 2, 2008

Recent Posts

I have created this ticket to avoid this in the future: LPS-30427
Regards,
Juan
sachin maheshwari
RE: How to get user's private page url
September 4, 2013 10:30 PM
Answer

sachin maheshwari

Rank: Junior Member

Posts: 52

Join Date: December 4, 2010

Recent Posts

This is the one i am looking for sort and simple.