Hi,
One way would be to get access to page itself and then check value of the property:
public class SomeSelectionFactory : ISelectionFactory { public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata) { // depending on master language - returning some stuff var masterLanguage = ((PageData)metadata.Parent.Model).MasterLanguage; ....
But this apporach is fragile in sense that child-parent depth is not deterministic. From the selection factory perspective you cannot be sure that 1st level parent will always be page itself (thinking about local blocks..).
Thanks Valdis, that approach was so close to being able to acheive my result. I can get the value I need but if I then change it, it doesn't hit the selection factory again until after a publish so the list does not get updated based on the new value selected.
May be this will be useful :-)
https://gregwiechec.com/2017/06/how-to-create-selectionfactory-with-parameters/
Hi Tahir,
That's useful thanks but not quite what I'm after. I need a list to be populated based on the value selected in another property, I kind of have this working but the selection factory is not called if I update the selected value of the other property.
Thanks,
Mark
Hi,
You can try http://nuget.episerver.com/en/OtherPages/Package/?packageId=DependentSelection and see if it works for you.
Disclaimer: I am the creator of this package. I mostly created it to test creating a EPiServer addon, so I cant guarantee that it works in all versions(10.x) of epi.
/Peter
Hi Peter,
That does sound good, sadly we're on an earlier version of EPiServer (7.19) at the moment.
Sure, go ahead Valdis:)
Mark, you might need to create a custom editor if you want the options to be updated without reloading the ui. Maybe http://world.episerver.com/Blogs/Duong-Nguyen/Dates/2014/1/Country-Region-drop-down-lists-in-All-properties-mode/ can help. I can't remember what works and what doesn't work in 7.x
/Peter
Hi,
I have a block property that uses a selection factory to provide a SelectOne and the data returned from the selection factory needs to be filtered based on the value of another property on the block.
Is this possible? If so how?
Thanks in advance,
Mark