Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Map Droplist item to complextype using Glass.Mapper

I have created two Sitecore templatates MenuItem and MainNavigation. I have created two interfaces wich are 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 mapping MenuItems from an MultiList is working. The mapping MenuHeaderItem from an Droplist is not. In the template I have provided an query in the datasource so only MenuItems can be selected.

How can I make this mapping work?

I've tried v4.0.5.54 and now I have updated to version 4.2.1.188

like image 857
Rene Avatar asked Feb 06 '23 03:02

Rene


1 Answers

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

Droplist only stores the selected item name as a string. Droplink also stores the GUID.

like image 115
Rene Avatar answered Mar 16 '23 23:03

Rene