Implementation issue in IUserCustomNavigationPlugin, IUserDefaultCustomNavigationPlugin

Former Member
Former Member

Hi Team,

I have implemented the following code to display the tab in profile page. But tab is not coming.

 public class UserMLRRewards : IPlugin, ITranslatablePlugin, IUserCustomNavigationPlugin, IUserDefaultCustomNavigationPlugin
    {
       private readonly Guid _defaultId = new Guid("0ac1a9e0-676d-4969-ae40-e9b9ad00751d");

        ITranslatablePluginController _translation;

        #region IPlugin
        public string Name
        {
            get { return "User MLR Rewards"; }
        }

        public string Description
        {
            get { return "Adds User MLR Rewards custom navigation support within user profile."; }
        }

        public void Initialize()
        {

        }
        #endregion
        #region IUserDefaultCustomNavigationPlugin Members
        public int DefaultOrderNumber
        {
            get { return 200; }
        }

        public ICustomNavigationItem GetDefaultNavigationItem(ICustomNavigationItemConfiguration configuration)
        {

            Telligent.Evolution.Extensibility.Api.Entities.Version1.User user = null;
            if (configuration.GetStringValue("user", "current") == "accessing")
                user = TEApi.Users.AccessingUser;
            else
            {
                var userItem = TEApi.Url.CurrentContext.ContextItems.GetItemByContentType(TEApi.Users.ContentTypeId);
                if (userItem != null)
                    user = TEApi.Users.Get(new UsersGetOptions() { ContentId = userItem.ContentId });
            }

            return new UserRewardsNavigationItem(this, configuration, _defaultId, user.Id.Value, () => _translation.GetLanguageResourceValue("configuration_defaultLabel"));
        }
        #endregion

        #region IUserCustomNavigationPlugin Members
        public ICustomNavigationItem GetNavigationItem(Guid id, ICustomNavigationItemConfiguration configuration)
        {
            Telligent.Evolution.Extensibility.Api.Entities.Version1.User user = null;
            if (configuration.GetStringValue("user", "current") == "accessing")
                user = TEApi.Users.AccessingUser;
            else
            {
                var userItem = TEApi.Url.CurrentContext.ContextItems.GetItemByContentType(TEApi.Users.ContentTypeId);
                if (userItem != null)
                    user = TEApi.Users.Get(new UsersGetOptions() { ContentId = userItem.ContentId });
            }

            return new UserRewardsNavigationItem(this, configuration, id, user.Id.Value, () => _translation.GetLanguageResourceValue("configuration_defaultLabel"));
        }

        public string NavigationTypeName
        {
            get { return _translation.GetLanguageResourceValue("navigation_type_name"); }
        }

        TEConfig.PropertyGroup[] IUserCustomNavigationPlugin.GetConfigurationProperties()
        {
            TEConfig.PropertyGroup group = new TEConfig.PropertyGroup();

            TEConfig.Property p = new TEConfig.Property()
            {
                Id = "user",
                LabelText = _translation.GetLanguageResourceValue("link_to_user"),
                DataType = "String",
                OrderNumber = 1,
                DefaultValue = "0",
                DescriptionText = "current"
            };

            p.SelectableValues.Add(new TEConfig.PropertyValue()
            {
                Value = "current",
                LabelText = _translation.GetLanguageResourceValue("link_to_user_current"),
                OrderNumber = 0
            });

            p.SelectableValues.Add(new TEConfig.PropertyValue()
            {
                Value = "accessing",
                LabelText = _translation.GetLanguageResourceValue("link_to_user_accessing"),
                OrderNumber = 1
            });

            group.Properties.Add(p);

            p = new TEConfig.Property()
            {
                Id = "label",
                LabelText = _translation.GetLanguageResourceValue("label"),
                DataType = "String",
                OrderNumber = 2,
                DefaultValue = "Rewards",
            };

            //p.ControlType = typeof(Telligent.Evolution.Controls.ContentFragmentTokenStringControl);
            group.Properties.Add(p);

            return new TEConfig.PropertyGroup[] { group };
        }
        #endregion
        #region ITranslatablePlugin Members
        public Translation[] DefaultTranslations
        {
            get
            {
                var translation = new Translation("en-US");
                translation.Set("navigation_type_name", "User Rewards");
                translation.Set("link_to_user", "User");
                translation.Set("link_to_user_current", "Contextual");
                translation.Set("link_to_user_accessing", "Accessing");
                translation.Set("configuration_defaultLabel", "Rewards");
                translation.Set("label", "Label");

                return new Translation[] { translation };
            }
        }

        public void SetController(ITranslatablePluginController controller)
        {
            _translation = controller;
        }

        #endregion






    }
    public class UserRewardsNavigationItem : ICustomNavigationItem
    {
        Func<string> _getLabel;
        int _userId;

        internal UserRewardsNavigationItem(ICustomNavigationPlugin plugin, ICustomNavigationItemConfiguration configuration, Guid id, int userId, Func<string> getLabel)
        {
            Plugin = plugin;
            Configuration = configuration;
            UniqueID = id;
            _userId = userId;
            _getLabel = getLabel;
        }
        #region ICustomNavigationItem Members

        public ICustomNavigationItem[] Children { get; set; }
        public ICustomNavigationItemConfiguration Configuration { get; private set; }
        public string CssClass { get { return "list-polls"; } }
        public string Label { get { return _getLabel(); } }
        public ICustomNavigationPlugin Plugin { get; private set; }
        public Guid UniqueID { get; private set; }

        public bool IsSelected(string currentFullUrl)
        {
            return TEApi.Url.CurrentContext.UrlName == "page-members-rewards";
        }

        public bool IsVisible(int userId)
        {
            return !string.IsNullOrEmpty(Url);
        }

        public string Url
        {
            get
            {
                return UserPolls(_userId);
            }
        }

        internal static string UserPolls(int userId)
        {
            var user = TEApi.Users.Get(new UsersGetOptions() { Id = userId });

            if (user == null)
                return null;

            return TEApi.Url.BuildUrl("page-members-rewards", new Dictionary<string, string>() { { "UserName", user.Username.ToLower().Replace(" ", "-") } });
        }

        #endregion
    }

I have enabled the plugin administration.

Added in page also

But tab is not coming

Please do the needful

Parents Reply Children
No Data