Check condition in Repeater Select top N pages

Vasyl Chepil asked on April 1, 2016 13:00

I'm using Repeater to show users blogs. Can i use condition in "Select top N pages" Repeater`s propertty. I need to check user role in this condition and if user role is "Blogger" show 12 blogs in other case show only 3.

Correct Answer

Vasyl Chepil answered on April 1, 2016 13:21

thanks this works good but it checks role of user that opens my page

but i need to check role of the user which userid i receive as a parameter in url

i tried this code {% (GetUserInfo(ToInt( QueryString["UserId"], 0 )).IsInRole("Blogger")?"1":"2") |(identity)GlobalAdministrator%} but it doesn't work

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dawid Jachnik answered on April 1, 2016 13:04 (last edited on December 10, 2019 02:30)

Hello,

yes, you can use macros in almost every property of web part. Here's your macro :)

{% (CurrentUser.IsInRole("Blogger")?"12":"3") |(identity)GlobalAdministrator%}
0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on April 1, 2016 13:31 (last edited on December 10, 2019 02:30)

try this one

{% (CMSContext.Current.GlobalObjects.Users.Where("UserID="+ToInt(QueryString["UserId"], 0 )).FirstItem.IsInRole("Blogger")?"1":"2") |(identity)GlobalAdministrator%}
2 votesVote for this answer Mark as a Correct answer

Vasyl Chepil answered on April 1, 2016 13:34

Thanks a lot. works fine

0 votesVote for this answer Mark as a Correct answer

Dawid Jachnik answered on April 1, 2016 14:06

Great correct answer... lol...

2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.