AI OnAI Off
Hi Thien,
You can reference the ContentData of the content which is using the SelectionFactory by casting the ExtendedMetadata object passed in to the GetSelections method as ContentDataMetadata and accessing the OwnerContent property.
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata) { var myContentData = (metadata as ContentDataMetadata)?.OwnerContent; // Do stuff here }
Bear in mind though that, depending what you're doing with it, selection factories are generally populated once when the editor loads and so it won't reflect changes made in the course of editing the rest of the page.
thank Paul, but your code always returns null when casting. Do you have any other idea?
I'm creating a custom selection factory which renders options base on another property value of current editing page.
Does Episerser has any API can get ContentData of current editing page or any extension can extract Page ID from edit mode URL?
Example:
https://dev.local/episerver/cms/?language=en-SG#context=epi.cms.contentdata:///1774&viewsetting=viewlanguage:///en-SG
I would like to get value 1774 from param "epi.cms.contendata"
Thanks for your help.