Fórumok
Hide a portlet and its boundarybased on a users role
bob brinks, módosítva 10 év-val korábban
Hide a portlet and its boundarybased on a users role
New Member Bejegyzések: 10 Csatlakozás dátuma: 2013.06.20. Legújabb bejegyzések
My suggestion:
[indent]I know i can hide a portlet using roles + permissions and layout.show.portlet.access.denied=false.
But what i'd like to see is an option to also hide the html taking the place of the 'hidden' portlet:
Or possibly add a css class so I can identify this portlet is not visible for the current user.
[/indent]
Then my question as well:
[indent]
Is there anyone who has done this with a hook or something like that in CE 6.1.2 version of liferay or the CE 6.2.0. And could you share the way you did it?
I'm currently using jQuery to fix this problem but it's causing some problems with the bootstrap 3 theme I made. It causes a lot of 'jumpiness' on the client after load.
[/indent]
[indent]I know i can hide a portlet using roles + permissions and layout.show.portlet.access.denied=false.
But what i'd like to see is an option to also hide the html taking the place of the 'hidden' portlet:
<div class="portlet-boundary portlet-boundary_portletName_WAR_portletName_ portlet-static portlet-static-end portlet-borderless document-publisher-portlet col-md-12 col-lg-12 col-sm-12" id="p_p_id_portletName_WAR_portletName_INSTANCE_Y096lxZEugka_">
<span id="p_portletName_WAR_portletName_INSTANCE_Y096lxZEugka"></span>
<div class="portlet-body">
</div>
</div>
Or possibly add a css class so I can identify this portlet is not visible for the current user.
[/indent]
Then my question as well:
[indent]
Is there anyone who has done this with a hook or something like that in CE 6.1.2 version of liferay or the CE 6.2.0. And could you share the way you did it?
I'm currently using jQuery to fix this problem but it's causing some problems with the bootstrap 3 theme I made. It causes a lot of 'jumpiness' on the client after load.
[/indent]
Victor Zorin, módosítva 10 év-val korábban
RE: Hide a portlet and its boundarybased on a users role
Liferay Legend Bejegyzések: 1228 Csatlakozás dátuma: 2008.04.14. Legújabb bejegyzések
If your theme uses for example jQuery you can invoke on page loading:
- find the element .portlet-boundary > .portlet-body
- check if it has empty content
- if yes, apply display: none to its direct parent, which is .portlet-boundary
Otherwise you would have to dig through jsps that handle portlets rendering and find the point where you would have to reverse the order of permissions and portlet rendering, which may be tricky or not possible due to sequencing.
- find the element .portlet-boundary > .portlet-body
- check if it has empty content
- if yes, apply display: none to its direct parent, which is .portlet-boundary
Otherwise you would have to dig through jsps that handle portlets rendering and find the point where you would have to reverse the order of permissions and portlet rendering, which may be tricky or not possible due to sequencing.
bob brinks, módosítva 10 év-val korábban
RE: Hide a portlet and its boundarybased on a users role
New Member Bejegyzések: 10 Csatlakozás dátuma: 2013.06.20. Legújabb bejegyzések
Thanks for your reply. jQuery was my current solution aswell but it's not a very 'nice' way to do this so I'm looking for something serverside.
I've updated the OP to specify this.
I've updated the OP to specify this.
Victor Zorin, módosítva 10 év-val korábban
RE: Hide a portlet and its boundarybased on a users role (Válasz)
Liferay Legend Bejegyzések: 1228 Csatlakozás dátuma: 2008.04.14. Legújabb bejegyzések
Yes, it would be jumpy, so had a quick look at jsps...
Try to investigate html/portal/render_portlet.jsp. Find lines:
cssClasses = "portlet-boundary ..." and
<div class="portlet-body">
below these lines you will see:
<c:when test="<%= !access && !portlet.isShowPortletAccessDenied() %>">
</c:when>
It looks like everything is available in one place and therefore it is feasible to add "display:none" or your own css class "hide" into cssClasses scriplet and/or next to "portlet-body" word.
Once it is working, make a standard jsp hook.
Try to investigate html/portal/render_portlet.jsp. Find lines:
cssClasses = "portlet-boundary ..." and
<div class="portlet-body">
below these lines you will see:
<c:when test="<%= !access && !portlet.isShowPortletAccessDenied() %>">
</c:when>
It looks like everything is available in one place and therefore it is feasible to add "display:none" or your own css class "hide" into cssClasses scriplet and/or next to "portlet-body" word.
Once it is working, make a standard jsp hook.
bob brinks, módosítva 10 év-val korábban
RE: Hide a portlet and its boundarybased on a users role
New Member Bejegyzések: 10 Csatlakozás dátuma: 2013.06.20. Legújabb bejegyzések
Thanks for looking into it, this will work great for my solution.