AI OnAI Off
Hi Ten Ten,
Quite simply we don't have this context in the selection factory, you're editing a block which has no direct relationship to a page. Is there a way you can rethink what you're trying to achieve?
The only "sort of" work-around I can this of is if you can ensure that the blocks are always created "For this page", then you could retrieve the page like this:
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var content = metadata.FindOwnerContent();
ContentAssetFolder assetFolder;
if (!_contentLoader.Service.TryGet(content.ParentLink, out assetFolder))
{
// Return defaults here
return new ISelectItem[0];
}
PageData page;
if (!_contentLoader.Service.TryGet(assetFolder.ContentOwnerID, out page))
{
// Return defaults here
return new ISelectItem[0];
}
return GetColorOptions(currentPage);
}
This feels kind of brittle though, so depends how important the integrity of the color selection is.
I have a page type that store some options, and I want to use them in a property (SelectOne) of a block type. When create a block, that property will get options from parent page (get in SelectionFactory). I tried to get current page by IPageRouteHelper but always return the HomePage
Thanks for your help.