Mapping External Template in Sitefinity with the API

August 05, 2013 Digital Experience
The ability to map external templates to different Sitefinity widgets is performed in the backend UI from Administration->Settings->Advanced->Controls->View Map.

To perform the mapping of a template trough code refer to the sample below:
var configManager = ConfigManager.GetManager();
            var viewMap = configManager.GetSection<ControlsConfig>();
            ConfigProperty property;
            var viewMapValue = viewMap.Properties.TryGetValue("viewMap", out property);
            string[][] bag = new string[4][];
 
            bag[0] = new string[2] { "Value", "Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations.SiteMapNavigationTabStrip, Telerik.Sitefinity" };
            bag[1] = new string[2] { "Key", "HostType" };
            bag[2] = new string[2] { "Value", "~/CustomNavigationTemplate.ascx" };
            bag[3] = new string[2] { "Key", "LayoutTemplatePath" };
 
 
            var ConfigSectionItems = new ConfigSectionItems();
            ConfigSectionItems.SaveBatchConfigSection(bag, "ViewMap_0,controlsConfig_0", "", "", null, "New", "");
The highlighted part of the code contains the required values for mapping a template, those are the host control type and a path to the mapped template.

Host:Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations.SiteMapNavigationTabStrip
Layout Template: ~/CustomNavigationTemplate.ascx

Additional approaches in mapping external templates are described in this blog post.

Stanislav Velikov

Stanislav Velikov is a Tech Support Engineer at Telerik. He joined the Sitefinity Support team in April 2011.