Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created March 28, 2023 10:58
Show Gist options
  • Select an option

  • Save hishaamn/5ec103d64747b63c12cc1db7134b18ee to your computer and use it in GitHub Desktop.

Select an option

Save hishaamn/5ec103d64747b63c12cc1db7134b18ee to your computer and use it in GitHub Desktop.
public class SxaDataView : BucketDataView
{
protected override void GetChildItems(ItemCollection items, Item item)
{
if (ItemIDs.MediaLibraryRoot == item.ID)
{
using (new LanguageSwitcher(item.Language))
{
Item rootItem = ServiceLocator.ServiceProvider.GetService<ISiteMediaRootProvider>().GetRootItem(item.Database);
if (rootItem != null)
item = rootItem;
}
}
using (new LanguageSwitcher(item.Language))
{
base.GetChildItems(items, item);
items.AddRange(item.GetVirtualChildren());
}
}
public override bool HasChildren(Item item, string filter) => base.HasChildren(item, filter) || item.HasVirtualChildren();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment