IApplicationNavigable route within a forum context - can't access current forum

I have a route for a page that needs to live under individual forums.  The route loads, but the system doesn't recognize I'm in a forum context when I hit the page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telligent.Evolution.Extensibility;
using Telligent.Evolution.Extensibility.Api.Version1;
using Telligent.Evolution.Extensibility.Urls.Version1;

namespace Extensions.Taxonomy.Plugins
{
    public class ForumTaxonomyNavigable : IApplicationNavigable
    {
        public Guid ApplicationTypeId
        {
            get { return Apis.Get<IForums>().ApplicationTypeId; }
        }

        public void RegisterUrls(IUrlController controller)
        {

            controller.AddPage("forum_taxonomy", "{ForumId}/taxonomy", null, null, "forum-taxonomy", new PageDefinitionOptions() {   Validate = ValidateAccess });
        }

        public string Description
        {
            get { return "Provides the url where the taxonomies are edited for each forum"; }
        }

        public void Initialize()
        {

        }

        public string Name
        {
            get { return "Forum Taxonomy Route"; }
        }

        private void ValidateAccess(PageContext context, IUrlAccessController controller)
        {
            if(!Apis.Get<IRoleUsers>().IsUserInRoles(Apis.Get<IUsers>().AccessingUser.Username, new string[] {"Administrators"}))
            {
                controller.AccessDenied("Access Denied", false);
            }
        }
    }
}

Parents Reply Children
  • I had an old ParseForumContext method in our 8.5 version, but now that the ID numbers are replaced with slugs...the parsing of the context isn't working.

            private void ParseForumContext(PageContext context)
            {
                var forumToken = context.GetTokenValue("ForumId");
                if (forumToken != null)
                {
                    int forumId = 0;
    
                    if (Int32.TryParse(forumToken.ToString(), out forumId))
                    {
                        var forum = Apis.Get<IForums>().Get(forumId);
                        if (forum != null)
                        {
                            ContextItem contextItem = new ContextItem()
                            {
                                TypeName = "Forum",
                                Id = forum.Id.ToString(),
                                ApplicationId = forum.ApplicationId,
                                ApplicationTypeId = Apis.Get<IForums>().ApplicationTypeId,
                                ContainerId = forum.Container.ContainerId,
                                ContainerTypeId = forum.Container.ContainerTypeId,
                                ContentTypeId = Apis.Get<IForums>().ContentTypeId,
                                ContentId = forum.ContentId
                            };
                            context.ContextItems.Put(contextItem);
                        }
                    }
                }
            }

  • What exactly is the Url?  Your route has the forumId in it so I am not sure why you are referring to application key as it would not be part of your url.

  • The original URL was something like /f/32/taxonomy

    When we went to 10.3, it looks like /f/the-forum-slug/taxonomy and that doesn't work now.  We had been tacking on "/taxonomy" to the URL, but now that the ID changed to a slug I'm wondering how to set the forum context