Map Droplist item to complextype using Glass.Mapper

I created two Sitecore templatates MenuItem and MainNavigation. I created two interfaces based on these templates:

 [SitecoreType(TemplateId = "{C824E484-F4A6-475C-AFAF-308FF4BBA5A9}", AutoMap = true)]
public interface IMenuItem
{
    string Title { get; set; }
    IEnumerable<IMenuItem> SubMenuItems { get; set; }
}
[SitecoreType(TemplateId = "{68947CC0-7658-4188-889D-4E88B84F3BC2}", AutoMap = true)]
public interface IMainNavigation
{        
    IMenuItem MenuHeaderItem { get; set; }

    IEnumerable<IMenuItem> MenuItems { get; set; }
}

The MenuItems from MultiList is displayed. Displaying a MenuHeaderItem from a Droplist is not. In the template, I provided a query in the data source, so you can only select MenuItems.

How can I do this mapping?

I tried v4.0.5.54 and now upgraded to version 4.2.1.188

+4
source share
2 answers

I myself found the answer. In the template, I have to use the sitecore Droplink type instead of DropList .

Droplist . Droplink GUID.

+7

, (. ) , :

[SitecoreField(FieldName = "MenuHeaderItem", FieldType = SitecoreFieldType.Droplist)]
+1

Source: https://habr.com/ru/post/1654788/


All Articles