Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

Question with EpiServer Property list

$
0
0

I had a property list with Name and Value. I made a selection factory to display the names to select one item from the property list. Following that I could get the value of the selected item in the UI. Sample code below.. 

public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
if (!_contentLoader.TryGet<HomePage>(ContentReference.StartPage, out var HomePage))
{
return Enumerable.Empty<ISelectItem>();
}
return HomePage.BannerAlertBackgroundColors?.Select(x => new SelectItem {Text = x.ColorName, Value = x.ColorHexValue });
}

This is how I used it in the block:

[SelectOne(SelectionFactoryType = typeof(BannerAlertColorSelectionFactory))]
public virtual string BannerBackgroundColor { get; set; }

I need to expand the property list to add one more item, Ex: Name, Value, Image. But I have to keep the implementation still same. User will be selecting the Name in the CMS. I need to update the selection factory some how to return the entire item so I can access Value and Image both in UI.

Any help is most appreciated.


Viewing all articles
Browse latest Browse all 6894

Trending Articles