Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
bo li
hide a portlet if the user not logged in
January 2, 2013 8:14 AM
Answer

bo li

Rank: Junior Member

Posts: 34

Join Date: November 14, 2011

Recent Posts

how to make a portlet not showing on the page, if the user has not logged in, same as the behavior of web content display portlet..


thanks!
Mitesh S Panchal
RE: hide a portlet if the user not logged in
January 2, 2013 8:37 AM
Answer

Mitesh S Panchal

Rank: New Member

Posts: 16

Join Date: December 10, 2008

Recent Posts

Hi

Simple thing is to assign permission such a way that only logged in user can see this portlet.

Thanks
Mitesh
bo li
RE: hide a portlet if the user not logged in
January 2, 2013 8:40 AM
Answer

bo li

Rank: Junior Member

Posts: 34

Join Date: November 14, 2011

Recent Posts

Could you give me the details about how to configure it this way? I think there is no way to make configuration for a logged in user, cuz it is not a role or something.
David H Nebinger
RE: hide a portlet if the user not logged in
January 2, 2013 9:05 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6275

Join Date: September 1, 2006

Recent Posts

Click on the wrench, choose Configuration, then Permissions, and uncheck the Guest's View permission.
bo li
RE: hide a portlet if the user not logged in
January 2, 2013 9:14 AM
Answer

bo li

Rank: Junior Member

Posts: 34

Join Date: November 14, 2011

Recent Posts

thanks for your help, this is not what I want.

If I configured it this way, when a user logged in, with a guest role, he also can not see the portlet.

The separation line is "logged in" or "not logged in".
Mitesh S Panchal
RE: hide a portlet if the user not logged in
January 2, 2013 2:36 PM
Answer

Mitesh S Panchal

Rank: New Member

Posts: 16

Join Date: December 10, 2008

Recent Posts

Hi

Can you configure your liferay instance to add all user as a community member ( can be done via control panel) ? this way user who are not logged in they have guest role and user who are logged in they have community role.
will that work for you?

other wise you need to update portlet to defect the logged vs not logged in and put similar code as web content display to hide portlet. you can find code snippet in web content display portlet src.

Thanks
Mitesh
bo li
RE: hide a portlet if the user not logged in
January 2, 2013 2:40 PM
Answer

bo li

Rank: Junior Member

Posts: 34

Join Date: November 14, 2011

Recent Posts

first solution should be working, I have used this approach earlier for another requirement.

I have found the code for achieving the same behavior as web content display.
renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.FALSE);

Thanks for your help!