Search code examples
sitecoreglass-mapper

Glass Mapper Droplink Show Name instead of Guid


I'm using glass mapper and my template has a droplink list in it. When i attempt to retreive the item, it's bringing back the selected guid in the droplink instead of the name. How do I go about showing the name selected in the droplink versus the guid?


Solution

  • If you'd like the name of the item instead of the GUID, why not use a Droplist? Or do you need the GUID for other purposes? Glass is simply returning what Sitecore is actually storing in this case (which for a Droplink would be the item GUID).

    Otherwise, you should create a new class for the linked item which includes the item name, and then change your mapped property to return that class instead of a string.

    FYI, though a Droplist might be the easier fix, use of that field type is not a good practice. Since the item name is stored instead of the GUID, changes to that item name do not cascade to linking items.