Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > WebPart - Visibility View modes: 
User avatar
Member
Member
tomaszj - 12/1/2010 8:36:11 AM
   
WebPart - Visibility
How to configure the WebPart to be visible only if CMSContext.CurrentUser.UserID equals SiteContext.CurrentUser.UserID?

User avatar
Kentico Support
Kentico Support
kentico_radekm - 12/1/2010 8:44:31 AM
   
RE:WebPart - Visibility
Hello.

You can use macro parameters (equals / notequals) as per this appendix in our Developer´s guide: http://devnet.kentico.com/docs/devguide/appendix_a___macro_expressions.htm

Best Regards,
Radek Macalik

User avatar
Member
Member
tomaszj - 12/1/2010 9:08:13 AM
   
RE:WebPart - Visibility
yes, macro but:
{%sitecontext.currentuser.userid|(equals)currentuser.userid%} - don't work
{(1)%sitecontext.currentuser.userid|(equals){(2)%currentuser.userid%(2)}|(user)michalv|(hash)1b22d0f96b082c5ee0b549090b52a0ed3028523eae215d570551063d17e03091%(1)} - don't work.
Nested macros don't work in version 5.5. It can be done differently?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/6/2010 8:37:07 AM
   
RE:WebPart - Visibility
Hi,

could you please apply the latest hotfix for 5.5 version? Unfortunately, there was a bug and nested macros were not resolved correctly. I am sorry for inconvenience. With the hotfix below macro will work.
{(1)%sitecontext.currentuser.userid|(equals){(2)%currentuser.userid%(2)}%(1)}

Best regards,
Ivana Tomanickova

User avatar
Member
Member
tomaszj - 12/7/2010 3:58:02 AM
   
RE:WebPart - Visibility
Hi,

5.5.3789 - don't work
5.5.3905 - don't work
5.5.3992 - don't work

To test this I added webpart Static Text with text as macro:
1: {(1)%sitecontext.currentuser.userid|(equals){(2)%currentuser.userid%(2)}|(user)michalv|(hash)1b22d0f96b082c5ee0b549090b52a0ed3028523eae215d570551063d17e03091%(1)}
2: {%sitecontext.currentuser.userid%}
4: {(1)%sitecontext.currentuser.userid|(equals){(2)%currentuser.userid%(2)}|(truevalue)T|(falsevalue)F|(user)michalv|(hash)f8fefe8f3ea8fc468fb7d55b8124a546f11b0edc9f5ceabf9d693303c97a968e%(1)}

Result:
1: False 2: 69 3: 69 4: F

expected result:
1: True 2: 69 3: 69 4: T

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/9/2010 1:46:38 AM
   
RE:WebPart - Visibility
Hi,

you will need to create a custom macro to compare above two macros. I did not realize it before and I am sorry for inconvenience.

The expression is not resolved correctly because the nested part of expression is resolved after the whole expression is resolved - in time of checking equals part, the nested part of macro is not resolved:
69|(equals){(2)%currentuser.userid%(2)} //returns false

A possibility to add a nested macro into equals part will be added in the version 6.0

Best regards,
Ivana Tomanickova