0
votes

I am very new in SharePoint. I'm using SharePoint 2013.

As a title of question. I want t create a page layout contain 4 webparts. Now I want to show / hide each of those webpart base on a condition ? How can I do that ?

Thank for any help.

1
are the web parts custom or Out of the box? - Truezplaya
I used custom webpart. - Ca Pham Van
Can you let us know what sort of condition you are thinking about? - Truezplaya
Yes. I have 4 custom webparts (wp A, B, C, D). My condition is: when current user has admin role (isAdmin = 1), the wp A, and B will be show, if current user has role is 0 (isAdmin = 0) show all wp. Other role only show wp C and D. - Ca Pham Van

1 Answers

0
votes

Could you use audience targeting for this? I'm not sure if this feature was removed from web parts but I know you could do it In so 2007.

The other option is to edit your web parts code. Perform a check onload, if it's true let it run through the it's normal rendering process otherwise hide. I'm not aware of a way you can do it via the page unless you use Js which I'm not sure is possible. Would be a good idea to make this a configurable web part property in case the web part needs to be available to all at a later date.

Hope this helps

Cheers

Truez