Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

"View as" not working in custom top menu

Vote:
 

I have a top menu that loads the top pages using the following code:

//get top level pages visible and in menu
IEnumerable allChilds = repository.GetChildren(ContentReference.StartPage);
IEnumerable filteredChilds = FilterForVisitor.Filter(new PageDataCollection(allChilds)).Where(p => p.IsVisibleOnSite() && p.VisibleInMenu);


My problem is that when the editor is using the "view as" and enables a specific visitor group, everything changes as it should except the menu. It seems like the p.IsVisibleOnSite() ignores the  chosen visitor group"

How can I fix this, anyone got any ideas?

#88971
Aug 05, 2014 10:28
Vote:
 

IsVisibleOnSite() has nothing to do with access rights, ref:
http://world.episerver.com/Documentation/Class-library/?documentId=cms/7.5/8726F47F

FilterForVisitor.Filter() runs FilterPublished(), FilterAccess() and FilterTemplate().

I thought that FilterAccess would remove any pages not relevant for chosen visitor group.

Could you try also running FilterContentForVistor?

#88976
Aug 05, 2014 12:08
Vote:
 

Thankyou for your answer Mari.

Tried FilterContentForVistor and same result. Note that this works perfektly in non-admin mode, using the same code. So I am thinking its editor-mode related.

#88981
Aug 05, 2014 13:34
Vote:
 

Ah, then FilterForVisitor does what it's supposed to.

I did a quick test in one of my projects and it works both from view mode and using "View as" functionality (using version 7.8). I gave access rights (read access) to the visitor group and removed read access for "Everyone" for the test-page.

 

#88982
Aug 05, 2014 14:02
Vote:
 

Mari, could you elaborate? Should I do extra tests in admin mode. Basically I just want to emulate what the users see. I'm on 7.5

#88985
Aug 05, 2014 14:18
Vote:
 

To test I did the following in edit mode:

  • Edit one of the pages in that is part of the main menu
  • Using the "Visible to" property I removed read access for "Everyone" and added read access for "VisitorGroup A"
  • I then navigated to start page, used "View settings" (eye icon) to select view for "VisitorGroup A".
  • I also opened the site in another browser where I was not logged (not part of visitor group) in to verify that the page was not visible
#88990
Aug 05, 2014 15:06
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.