callumbwhyte / meganav

A flexible, draggable link picker for constructing site navigation menus in Umbraco
MIT License
35 stars 34 forks source link

Links to unpublished content returns as ItemType.Link without Title #44

Closed ronaldbarendse closed 2 years ago

ronaldbarendse commented 4 years ago

When a content link is added, the Content and Title property are correctly set in the MeganavValueConverter PVC, but as soon as that content is unpublished/removed, both are null and the ItemType changes to Link (and it's still returned by the PVC).

The Id property still holds the correct content ID though, so as a workaround we currently filter these out (in our views): .Where(item => !(item.Id != 0 && item.Content == null)).

I would make sure the PVC doesn't return links to unavailable content, as that doesn't make sense anyway. Looking at the code, this was probably also intended that way:

https://github.com/callumbwhyte/meganav/blob/10ebec64b37a4ce024de66b5fe0bf873794bcac5/src/Cogworks.Meganav/ValueConverters/MeganavValueConverter.cs#L65-L72

https://github.com/callumbwhyte/meganav/blob/10ebec64b37a4ce024de66b5fe0bf873794bcac5/src/Cogworks.Meganav/ValueConverters/MeganavValueConverter.cs#L100-L101

It's probably better to remove the LINQ query, return a new list (or yield the items) and just skip all items with Id > 0 and umbracoContent == null.

callumbwhyte commented 2 years ago

Closing as this logic no longer exists in V2 or V3.