DefaultPageXML in custom Route

What type of XML can I put in the DefaultPageXML param of a custom Route?  I exported a page, but not sure if it needs the entire export or only what is in the ContentFragmentPage node?

controller.AddPage(page.PageKey, page.RoutePath, null, null, page.PageKey, new PageDefinitionOptions() {DefaultPageXml ParseContext = ParseCMSPageContext });

 <contentFragmentPage pageName="family-services" isCustom="false" layout="Content" themeType="0c647246-6735-42f9-875d-c8b991fe739b" lastModified="2019-05-30 05:50:02Z">
      <regions>
        <region regionName="Content">
          <contentFragments>
            <contentFragment type="Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.Platform::50c816b46c7647d5a7cea85b3f47d4d6" showHeader="True" cssClassAddition="top-border with-spacing with-header responsive-1" isLocked="False" configuration="title=Family%20Services&html=%3Cp%3EFamily%20Services%20content%20goes%20here.%3C%2Fp%3E&backgroundImage=&width=page&cssClass=" />
          </contentFragments>
        </region>
      </regions>
      <contentFragmentTabs />
    </contentFragmentPage>

Parents Reply
  • A few things to check:

    1. Ensure that you can import the XML above -- you'll need to wrap it as if it was from an export. Unfortunately, deserialization issues with default page definition XML will not currently be logged.

    2. Did you also, by chance, define a factory default in the theme (in filestorage/factorydefaultpages/[theme_id]/[theme_type_id].xml? Any definition in this file will override the route page definition.

    3. Is there a default saved for this page already? If so, you should see a revert option when editing the default version of the page.

Children
  • Thanks Ben...my XML didn't import, so I wrapped it...that imported, but still didn't set the Default when I set it via the Route declaration.  There is no factory default, and no default saved.

  • When are you adding the page to the navigable controller? Is this when the controller is provided or later? If its later, the default may not be picked up in the resolved/cached theme definition. You could try expiring the UI cache through Administration > About to see if this is the case.

  • Yes.

            public void RegisterUrls(IUrlController controller)
            {
    
    
    
                    var db = new Data.CMSPageDataProvider();
                    var pages = db.ListCMSPages();
                    var config = Components.CMSPages.ListPageTypes();
    
                    foreach (Entities.CMSPage page in pages)
                    {
                        if (page.GroupId.Equals(Apis.Get<IGroups>().Root.Id.Value))
                        {
                            var definition = (from c in config where c.Key.Equals(page.PageTypeKey) select c).First();
                            string defaultXml = Uri.UnescapeDataString(Regex.Unescape(String.Format(definition.DefaultXmlLayout, page.PageKey).Trim())).Replace("\\","");
                            controller.AddPage(page.PageKey, page.RoutePath, null, null, page.PageKey, new PageDefinitionOptions() { DefaultPageXml = defaultXml, ParseContext = ParseCMSPageContext });
                        }
                    }
    
            }

  • Do you have an example of some XML that would work for the controller.AddPage method?

  • Yes, this is the definition for the user-customizable homepage:

    private readonly string userHomePageXml = @"<contentFragmentPage pageName=""common-home"" isCustom=""false"" layout=""Content"" themeType=""294234b2-9505-40a9-a679-93162fd50c1c"">
        <regions>
          <region regionName=""Content"" >
            <contentFragments>
              <contentFragment type=""Telligent.Evolution.ScriptedContentFragments.ScriptedContentFragment, Telligent.Evolution.Platform::906f3e32e53c4dce8bc495d8c9bd83ff"" showHeader=""False"" cssClassAddition=""no-wrapper with-spacing responsive-1"" isLocked=""False"" configuration="""" />
            </contentFragments>
          </region>
        </regions>
        <contentFragmentTabs />
      </contentFragmentPage>";
    
    public void RegisterUrls(IUrlController controller) {
        controller.AddPage("home", "", null, null, "common-home", new PageDefinitionOptions()
        {
        	ParseContext = ParseUserContext,
        	SetCustomPageOutput = (p, c) => AddHeaders(p, c),
        	TitleFunction = () => _translation.GetLanguageResourceValue("page-common-home-site"),
        	DescriptionFunction = () => _translation.GetLanguageResourceValue("page-common-home-site-description"),
        	DefaultPageXml = userHomePageXml
        });
    }

  • Thanks Ben.  I got it working now!  I was saving the default XML for the page in a text box in a Plugin config.  Appears when the text was rendering in the control panel for me to edit, after saving, it was replacing the &amp; with just an &, which the XML compiler didn't like and was logging the exception but not preventing the route from loading.

  • I pasted in XML from the page export, but when the plugin saved, it got rid of the &amp;