Plug-in that acts like content page

Is there a way to create a plug-in that acts like a content page? I would like to add a route, but every page that renders under that route has its own configuration

/key1/{page key1}

/key1/{page key}

one route, but have different widgets on each page

Parents Reply Children
  • Right, that's why we're using a bunch of Custom Pages under a sub-group. Works great. I'm too new to explain details on Routed Pages so I'll leave that to the community, best of luck.

  • My train of thought is now thinking an INavigable Plug-in that registers routes dynamically from sort configuration or XML file. Question would be when does the route table get refreshed?

  • Its 1 set of widgets, 1 layout per route, so you are not going to be able to have dynamic layouts.   If you want different layouts or widgets, it will need to be separate pages/routes.

    Note that you can have dynamic values in your route, but the layout tied to it is static.

    The routes get refreshed like standard route tables, when the app restarts and plugins reload.  

  • Thanks - would enabling/disabling the plugin cause the routes to reload?

  • It should, there is a bug for application routes I think was just fixed, but standard INavigable should be fine

  • Thanks Patrick.

    Context:  We are investigating moving most of our website over to Telligent.  Management would like to have the same URL structure.  So plan is to have a Plugin that implements INavigable and possibly some sort of multi-line String configuration that takes in XML which would basically define  custom routes.

    In the RegisterRoutes method, plugin would read that XML, parse it and loop through it and register a custom route for each node, thus letting us add a custom route by updating plugin config XML field...

    Routes would basically look like:
    /category/pagename


  • Here is what I have for a working POC.
    Plugin is configurable - takes XML as input.
    Plugin reads the XML and registers routes based on the XML
    Plugin creates empty pages for each route.  
    Route actually gets refreshed/added when the configuration is updated, no need to dsable/re-enable the plugin.

    This is intended to create custom blank pages for the purpose of building out a custom content page.  Almost exactly like themed content pages, but without the /p/ in the URL

    Here is the plugin - very rough, but works.  Anything here that could get me into trouble???

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml;
    using System.Xml.Linq;
    using Telligent.DynamicConfiguration.Components;
    using Telligent.Evolution.Extensibility.Urls.Version1;
    using Telligent.Evolution.Extensibility.Version1;
    
    namespace SampleNamespace.CMS
    {
        public class CMSPlugin : IPlugin, IConfigurablePlugin, INavigable
        {
            private IPluginConfiguration _config;
            public const string ROUTE_XML_CONFIG_KEY = "routeXml";
    
            #region IPlugin Members
            public string Description
            {
                get
                {
                    return "Implements custom dynamic routes for CMS pages";
                }
            }
    
            public string Name
            {
                get
                {
                    return "CMS Plugin";
                }
            }
    
            public void Initialize()
            {
                
            }
            #endregion
            #region IConfigurablePlugin Members
            public PropertyGroup[] ConfigurationOptions
            {
                get
                {
                    // Options
                    var group = new PropertyGroup("options", "Options", 0);
    
                    // XML
                    var xml = new Property(ROUTE_XML_CONFIG_KEY, "Custom Routes XML", PropertyType.String, 1, string.Empty)
                    {
                        DescriptionText = "XML Document defining custom CMS page routes",
                        ControlType = typeof(Telligent.DynamicConfiguration.Controls.MultilineStringControl)
                    };
                    group.Properties.Add(xml);
    
                    return new[] { group };
                }
            }
    
            public void Update(IPluginConfiguration configuration)
            {
                _config = configuration;
            }
    
            public string GetConfigurationString(string key)
            {
                return _config.GetString(key);
            }
            #endregion
    
            #region INavigable Members
            public void RegisterUrls(IUrlController controller)
            {
                try
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(this.GetConfigurationString(ROUTE_XML_CONFIG_KEY));
    
                    var routes = doc.GetElementsByTagName("Route");
                    foreach (XmlNode route in routes)
                    {
                        controller.AddPage(route.SelectSingleNode("key").InnerText, route.SelectSingleNode("route").InnerText, null, null, route.SelectSingleNode("key").InnerText, new PageDefinitionOptions() { });
                    }
                }
                catch { }
            }
            #endregion
        }
    }
    

    <?xml version="1.0" encoding="utf-8"?>
    <Routes>
      <Route>
        <key>my-page-one</key>
        <route>my-page-one</route>
      </Route>
      <Route>
        <key>page-one-links</key>
        <route>my-page-one/links</route>
      </Route>
    </Routes>