Skip to content

Instantly share code, notes, and snippets.

@VesselinVassilev
Created July 26, 2018 03:03
Show Gist options
  • Select an option

  • Save VesselinVassilev/0b71d85562b86366d61462be09439860 to your computer and use it in GitHub Desktop.

Select an option

Save VesselinVassilev/0b71d85562b86366d61462be09439860 to your computer and use it in GitHub Desktop.
Filter dynamic content items
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"));
@jonbenwaa
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment