am I implementing the Version 3 CustomNavigationItem correctly?

the problem I'm having is the default label is missing and when I edit the widget, I can see a GUID instead of "Map Apps"  the so here is my code and then below that a screen shot:

 public class MapsGroupNavigationItem : TeeuV3.CustomNavigationItem
        {
            int _groupId = -1;
            Func<string> _getLabel;
            IList<PublicApi.Entities.MapApp> _mapapps;
            internal MapsGroupNavigationItem(TeeuV3.ICustomNavigationPlugin plugin, TeeuV3.ICustomNavigationItemConfiguration configuration, Guid id, int groupId, Func<string> getLabel)
            {
                Plugin = plugin;
                Configuration = configuration;
                UniqueID = id;
                 
                _groupId = groupId;
                _getLabel = getLabel;
           
            }

            #region ICustomNavigationItem Members

            public TeeuV3.CustomNavigationItem[] Children { get; set; }
            public TeeuV3.ICustomNavigationItemConfiguration Configuration { get; private set; }
            public string CssClass { get { return "mapapp"; } }
            public string Label { get { return _getLabel(); } }
            public TeeuV3.ICustomNavigationPlugin Plugin { get; private set; }
            public Guid UniqueID { get; private set; }

            public new bool IsSelected(string currentFullUrl)
            {
                return currentFullUrl.Contains("/mapapps/") || currentFullUrl.EndsWith("/mapapps") || currentFullUrl.EndsWith("/mapapps/");
            }

            public new bool IsVisible(int userId)
            {
                return !string.IsNullOrEmpty(Url) &&  PublicApi.MapApps.CanRead(_mapapps.FirstOrDefault().ApplicationId);
            }

            public string Url
            {
                get
                {
                    // if (_groupId == -1) { return null; }
                    if (_mapapps != null && _mapapps.Count > 0)
                    {
                        if (_mapapps.Count == 1)
                        {
                            if (_mapapps.FirstOrDefault().Group != null && _mapapps.FirstOrDefault().Group.Url != null)// && _mapapp.SafeName != null)
                            {
                                return _mapapps.FirstOrDefault().Group.Url + "mapapps/" + _mapapps.FirstOrDefault().SafeName + "/maps/"; // InternalApi.SourceingUrlService.SourceListUrl(_groupId);
                            }
                        }
                        else
                        {
                            if (_mapapps.FirstOrDefault().Group != null && _mapapps.FirstOrDefault().Group.Url != null)// && _mapapp.SafeName != null)
                            {
                                return _mapapps.FirstOrDefault().Group.Url + "mapapps/";
                            }
                        }
                    }
                   // return _mapapps.FirstOrDefault().Group.Url + "mapapps/";
                   return "";
                }
            }

            #endregion
        }


  • I think I know what I did wrong above.. testing it now, but it looks like I am not setting the Default Label, or Default Description.. both are a Func<string>..
    I think in the above, using the interface, I was using some logic to set the Label and URL.. but just to confirm, used this code to set it and I see the Label now instead of the GUID
    so that's good.. but it's not showing up in the menu

      CustomNavigationItem IGroupDefaultCustomNavigationPlugin.GetDefaultNavigationItem(int groupId, ICustomNavigationItemConfiguration configuration)
            {
                CustomNavigationItem newItem = new MapsGroupNavigationItem(this, configuration, _defaultId, groupId, () => _translation.GetLanguageResourceValue("configuration_defaultLabel"));
                newItem.DefaultLabel = GetDefaultLabel;
                newItem.DefaultDescription = GetDefaultLabelDescription;
                return newItem;
            }




    for example, this drop down navigation menu or the Groups navigation tabs

    as the following doesn't show any links after the "Tags" item



  • Was able to migrate the original code from 9.x to 12.x
    The isVisible may need a permission for it however.. so for now it's always true


    And nice to see it also selects the item.. so it shows up in the cookie crumb path.


    So the solution is to Create the CustomNavigationItem object, so using a new object, and populate all 6 properties. When it applies  

          private CustomNavigationItem GetCustomNavigationItem( int groupId )
            {
                CustomNavigationItem newItem = new CustomNavigationItem();
                newItem.DefaultLabel = GetDefaultLabel;
                newItem.DefaultDescription = GetDefaultLabelDescription;
                 
                if (groupId > -1)
                {
                    IList<PublicApi.Entities.MapApp> _mapapps = PublicApi.MapApps.List(groupId);
                    if (_mapapps != null && _mapapps.Count > 0)
                    {
                        if (_mapapps.FirstOrDefault().Group != null)
                        {
                            newItem.DefaultAvatarUrl = _mapapps.FirstOrDefault().Group.AvatarUrl;
                            newItem.CssClass = "community-map-apps";
                            newItem.IsVisible = CustomeNavigationItemIsVisible;
                            newItem.IsSelected = CustomNavigationItemIsSelected;
    
                            if (_mapapps.Count == 1)
                            {
    
                                PublicApi.Entities.MapApp _mapApp = _mapapps.FirstOrDefault();
    
                                if (_mapApp.Group != null && _mapApp.Group.Url != null)
                                {
                                    newItem.DefaultLabel = () => _mapApp.Name;
                                    newItem.Url = _mapApp.Group.Url + "mapapps/" + _mapApp.SafeName + "/maps/";
                                }
                            }
                            else
                            {
                                if (_mapapps.FirstOrDefault().Group != null && _mapapps.FirstOrDefault().Group.Url != null)// && _mapapp.SafeName != null)
                                {
                                    newItem.Url = _mapapps.FirstOrDefault().Group.Url + "mapapps/";
                                }
                            }
                        }
                    }
    
                }
    
                return newItem;
            }


    The IsVisible and the IsSelected 
    bool CustomeNavigationItemIsVisible(int accessingUserId) 
            {
                _accessingUserId = (int)accessingUserId;
                // need a check to see if permission is allowed            
                return true;
            }
            bool CustomNavigationItemIsSelected(string currentFullUrl, Telligent.Evolution.Extensibility.Urls.Version1.PageContext PageContext ) 
            {
                bool isSelected = false;
                if (currentFullUrl.Contains("/mapapps/") || currentFullUrl.EndsWith("/mapapps") || currentFullUrl.EndsWith("/mapapps/"))
                {
                    isSelected = true;
                }
                return isSelected;
            }

    and the Label with label Description

         private string GetDefaultLabel () 
            {
                string label =  _translation.GetLanguageResourceValue("configuration_defaultLabel");
                return label;  
            }
          
            private string GetDefaultLabelDescription() 
            {
                string label_description = _translation.GetLanguageResourceValue("configuration_defaultLabel_description");
                return label_description; 
            }


    there is not much more if you are following the polling app, just change the way the Custom Navigation Item is handled.