Code above looks good. What's the problem with just unchecking "Visible in menu" for existing pages in admin mode?
If you want to hide all pages for some page type you can add a separate
.Where(x=> x as YourPageType ==null)
or even better, create an interface IHideFromMenu with a method HideFromMenu (=>true) and implement that on pagetype and check vs that. Then you can do something like:
.Where(x=>x as IHideFromMenu == null || ((IHideFromMenu)x).HideFromMenu==false)
It's nice with strongly typed page types now. You can actually use SOLID principles etc :)
problem is even if I uncheck the checkbox, for existing content (instance), the value of VisibleInMenu shows True. What I observed is if I create new instance of the page type, then VisibleInMenu sets to false and I'm not seeing the same in my Menu. Please see attached print screen of property Display In Navigation is set to uncheck (false) from the admin mode, and in debug mode for the same page type, VisibleInMenu value as true and therefore I could see it in my menu. I was hoping by setting Display In Navigation to uncheck (false), VisibleInMenu property should set to false.
Let me know if I'm missing or doing something wrong. I hope you would see the image (i hope one can see the attached image, because for me I just see image description. I am guessing, submitting the post it will upload and show the image.) Do let me know if you can't see the image.
I agree by implementing interface we could check but instead is there no way using property (so that editor could set/reset) it can be controlled. Like I was hoping using VisibleInMenu editor could change the way how menu item look/visible for existing content. I think default values work for new content and not for already created content. Is there any workaround to tweak default values in the existing contents?
Thanks and Regards
I'm learning EpiServer (Version 10). I have created few page type instances and then by looping through top level pages I am displaying them in my menu. Please see below code snippet used to get top level pages. Now I want to hide one of the menu items.
Firt try i gave by overriding set default values (this.VisibleInMenu=false). This worked for any new content type that I create based on that page type. But I wanted to hide existing menu item (content created). So other option I tried using Admin mode and under Content Type Tab and particular page type, clicked on Settings button. Then I checked the check box "Use adjusted default settings for pages using this page type" and unchecked the Display in navigation. But having set that property to false, still the page type was showing me in the menu.
I also read that I need to probably run the synchronization step to update my existing content, but I don't get that too, how to run that.
Am I missing anything here?
Also would like to know if we can do something like, for a subpage we should have the option to choose if we want a sublink to appear?
thanks and and regards