Created
July 26, 2018 03:03
-
-
Save VesselinVassilev/0b71d85562b86366d61462be09439860 to your computer and use it in GitHub Desktop.
Filter dynamic content items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IQueryable<DynamicContent> GetLiveDataItemsForType(this DynamicModuleManager manager, string type) | |
| { | |
| Type resolvedType = TypeResolutionService.ResolveType(type); | |
| return manager.GetDataItems(resolvedType) | |
| .Where(i => i.Status == ContentLifecycleStatus.Live && i.Visible); | |
| } | |
| .... | |
| var manager = DynamicModuleManager.GetManager(); | |
| var affiliates = manager.GetLiveDataItemsForType("yourFullTypeName") | |
| .Where(a => a.GetValue<bool>("ListOnSearchPage") == true) | |
| .Where(a => a.GetValue<bool>("Enabled") == true) | |
| // dynamic linq below just for demo | |
| .Where(" {0}.Equals(\"{1}\") ".Arrange("AffiliateStatus", (int)AffiliateStatus.Approved)) | |
| .OrderBy(a => a.GetValue<string>("Title")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!