+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Module Builder - DynamicModulesConfig.config

Module Builder - DynamicModulesConfig.config

18 posts, 0 answered
  1. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    06 Jan 2012
    Link to this post
    Is it possible to add a "conditional" statement to the clienttemplate field in the config file.  for instance formatting plural and singular depending on a numeric value?
  2. Kristian Smilenov
    Kristian Smilenov avatar
    32 posts
    Registered:
    18 Mar 2015
    09 Jan 2012
    Link to this post
    Hello Victor, 

    Thank you for contacting us.

    Can you please specify which client template do you mean in which config file? A little more description of the problem is always helpful.

    Kind regards,
    Kristian Smilenov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    09 Jan 2012
    Link to this post
    Take this as an example:

    <
    add clientTemplate="<a sys:href='javascript:void(0);' sys:class="{{'sysNumApps'}}" >{{NumApplications}} application(s)</a>" name="NumApplications" headerText="Applications" type:this="Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend.Master.Config.DataColumnElement, Telerik.Sitefinity" />

    If NumApplications =0, then I want "No applications", If NumApplications=1, then 1 application, anything else, 2,3,4, applications etc.

    Also, using {{FieldName}} inside the href property show the literal "{{FieldName}}", not the the DB value.
  4. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    10 Jan 2012
    Link to this post
     Hi Victor,

    You can use the following code for your first question

    {{(NumApplications == 0 ? 'No applications' : (NumApplications == 1 ? '1 application' : NumApplications + ' applications'))}}

    As for the second question - do you define the href attribute as "href" or "sys:href" ? Could you try with just "href".

    Greetings,
    Lubomir Velkov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    10 Jan 2012
    Link to this post
    As for the 2nd question, I've tried it both way.  Both ways give the same result.
  6. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    12 Jan 2012
    Link to this post
    Hello Victor,

    I just tested with the following:

    <a sys:href='{{Title}}'>Title</a>

    And the actual Title was rendered. Are you sure the attribute that you bind to is present on the client via the ViewModel?

    Regards,
    Lubomir Velkov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Beth
    Beth avatar
    25 posts
    Registered:
    20 Aug 2012
    18 Jul 2012
    Link to this post
    If I edit the module from the Module Builder after doing these edits to the DynamicModuleConfig.config, the DynamicModuleConfig.config. 

    Other than backing up and merging files is there not another way to edit the config programmatically? Something like with is placed in the Global.asax? 

    var section = Telerik.Sitefinity.Configuration.Config.Get<SearchConfig>();
               foreach (var provider in section.Providers.Values)
               {
                   if (provider.Name == "LuceneSearchProvider")
                   {
                       if (provider.ProviderType == typeof(LuceneSearchProvider))
                       {
                           provider.ProviderType = typeof(LucenseCustomSearchProvider);
                           Telerik.Sitefinity.Configuration.ConfigManager.GetManager().SaveSection(section);
                           break;
                       }
                   }
               }
  8. Beth
    Beth avatar
    25 posts
    Registered:
    20 Aug 2012
    18 Jul 2012
    Link to this post
    If I edit the module from the Module Builder after doing these edits to the DynamicModuleConfig.config, the DynamicModuleConfig.config. 

    Other than backing up and merging files is there not another way to edit the config programmatically? Something like with is placed in the Global.asax? 

    var section = Telerik.Sitefinity.Configuration.Config.Get<SearchConfig>();
               foreach (var provider in section.Providers.Values)
               {
                   if (provider.Name == "LuceneSearchProvider")
                   {
                       if (provider.ProviderType == typeof(LuceneSearchProvider))
                       {
                           provider.ProviderType = typeof(LucenseCustomSearchProvider);
                           Telerik.Sitefinity.Configuration.ConfigManager.GetManager().SaveSection(section);
                           break;
                       }
                   }
               }
  9. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    06 Mar 2013
    Link to this post

    Any update on this? Telerik.Sitefinity.DynamicModules.Configuration.DynamicModulesConfig is marked as an internal class. Is there another way to modify DynamicModulesConfig.config programmatically?

  10. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    09 Dec 2016
    11 Mar 2013
    Link to this post
    Hi Basem,


    That's a tough one, we have not exposed the complete API for ModuleBuilder yet, as there are still some features we plan on implementing, which makes delivering backward compatibility very tough if the API is made public now.

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Adam
    Adam avatar
    23 posts
    Registered:
    05 Apr 2013
    30 May 2013 in reply to Boyan Barnev
    Link to this post
    Is there a workaround? I too need to force values into dynamic modules config because they get blown away when updating the module. PLEASE HELP! thanks
  12. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    31 May 2013 in reply to Adam
    Link to this post
    Adam,

    From the developers community in google.  Steve posted this link:

    http://www.sitefinity.com/documentation/documentationarticles/developers-guide/deep-dive/configuration/creating-configuration-classes

    If you scroll down to the section "Reading and modifying configuration"
    This is where you make the changes.  Now I haven't had a chance to actually test this (SF please confirm), but you would run this in the bootstrapper event and this would "persist" your actually config changes.

  13. Adam
    Adam avatar
    23 posts
    Registered:
    05 Apr 2013
    31 May 2013 in reply to Victor
    Link to this post
    Thanks, but isn't that for new config sections? Also, creating a class from scratch that works like DynamicModulesConfig could be a huge time investment...
  14. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    31 May 2013 in reply to Adam
    Link to this post
    No.  Scroll down to "To modify values from PageAppearanceConfig.config, use the following code:"

    But instead you would modify DynamicModulesConfig.config
  15. Adam
    Adam avatar
    23 posts
    Registered:
    05 Apr 2013
    31 May 2013 in reply to Victor
    Link to this post
    Yes, but to modify DynamicModulesConfig.config, you need a class that wraps that config file. That class (DynamicModulesConfig) is internal and can't be accessed by us.
  16. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    31 May 2013 in reply to Adam
    Link to this post
    Technically, you can't, but you can write your own (use JustDecompile).
  17. Basem
    Basem avatar
    131 posts
    Registered:
    22 Dec 2010
    31 May 2013
    Link to this post
    As a workaround, I am working with the DynamicConfig.config file purely as an XML file and works pretty well. I just have to remember to restart the application after doing this.

    public static void ExtendSomeDynamicConfig()
    {
        /// TODO: WORK AROUND UNTIL NO LONGER AN INTERNAL CLASS:
        /// Telerik.Sitefinity.DynamicModules.Configuration.DynamicModulesConfig
        try
        {
            //MODIFY DYNAMIC MODULES CONFIG IF APPLICABLE
            string file = HostingEnvironment.MapPath("~/App_Data/Sitefinity/Configuration/DynamicModulesConfig.config");
            if (File.Exists(file))
            {
                //GET RAW XML FILE
                var doc = new XmlDocument();
                doc.Load(file);
     
                //TODO: MANUALLY MODIFY DYNAMIC MODULES CONFIG UNTIL SF API AVAILABLE
                var root = doc.SelectSingleNode("dynamicModulesConfig/contentViewControls/contentViewControl[@contentType='Telerik.Sitefinity.DynamicTypes.Model.Widgetblocks.WidgetBlock']");
                if (root != null)
                {
                    //GET ROOT PARENTS FOR WIDGET BLOCKS NODE
                    var list = root.SelectSingleNode("views/view[@viewName='Widget blockBackendList']");
                    var listToolbar = list.SelectSingleNode("toolbar/sections/section[@name='toolbar']/items");
                    var listActions = list.SelectSingleNode("viewModes/add[@Name='Grid']/columns/add[@name='Actions']/menuItems");
                    var listScripts = list.SelectSingleNode("scripts");
                    var detailInsert = root.SelectSingleNode("views/view[@viewName='Widget blockBackendInsertView']");
                    var detailUpdate = root.SelectSingleNode("views/view[@viewName='Widget blockBackendEditView']");
                    var detailPreview = root.SelectSingleNode("views/view[@viewName='Widget blockBackendPreviewView']");
                    bool changed = false; //TRACK CHANGES MANUALLY SINCE NO ISDIRTY FLAG ON XMLDOCUMENT
     
                    //ADD NEW DUPLICATE BUTTON IF APPLICABLE
                    var duplicate = listActions.SelectSingleNode("menuItem[@name='Duplicate']");
                    if (duplicate == null)
                    {
                        //CREATE ELEMENT FROM XML FOR ACTION ITEMS
                        var element = doc.CreateElement("menuItem");
                        element.SetAttribute("commandName", "duplicate");
                        element.SetAttribute("commandButtonType", "Standard");
                        element.SetAttribute("isFilter", "False");
                        element.SetAttribute("cssClass", "sfDuplicateItm");
                        element.SetAttribute("text", "Duplicate");
                        element.SetAttribute("wrapperTagKey", "Li");
                        element.SetAttribute("widgetType", "Telerik.Sitefinity.Web.UI.Backend.Elements.Widgets.CommandWidget, Telerik.Sitefinity");
                        element.SetAttribute("isSeparator", "False");
                        element.SetAttribute("name", "Duplicate");
                        element.SetAttribute("this", "urn:telerik:sitefinity:configuration:type", "Telerik.Sitefinity.Web.UI.Backend.Elements.Config.CommandWidgetElement, Telerik.Sitefinity");
     
                        //ADD TO EXISTING ACTION ITEMS
                        listActions.AppendChild(element);
                        changed = true;
                    }
     
                    //ADD NEW MARKETPLACE BUTTON IF APPLICABLE
                    var marketplace = listToolbar.SelectSingleNode("item[@name='MarketplaceWidget']");
                    if (ConfigHelper.GetAppSetting<bool>(Constants.KEY_TORNADO_ENABLE_MARKETPLACE) && marketplace == null)
                    {
                        //CREATE ELEMENT FROM XML FOR ADMIN TOOLBAR
                        var element = doc.CreateElement("item");
                        element.SetAttribute("persistentTypeToSearch", "Telerik.Sitefinity.GenericContent.Model.Content, Telerik.Sitefinity.Model");
                        element.SetAttribute("mode", "NotSet");
                        element.SetAttribute("commandName", "marketplace");
                        element.SetAttribute("commandButtonType", "Standard");
                        element.SetAttribute("isFilter", "False");
                        element.SetAttribute("text", "Marketplace...");
                        element.SetAttribute("wrapperTagKey", "Unknown");
                        element.SetAttribute("widgetType", "Falafel.Sitefinity.Web.Elements.MarketplaceWidget, Falafel.Sitefinity");
                        element.SetAttribute("isSeparator", "False");
                        element.SetAttribute("name", "MarketplaceWidget");
                        element.SetAttribute("this", "urn:telerik:sitefinity:configuration:type", "Telerik.Sitefinity.Web.UI.Backend.Elements.Config.SearchWidgetElement, Telerik.Sitefinity");
     
                        //ADD TO EXISTING TOOLBAR
                        listToolbar.AppendChild(element);
                        changed = true;
                    }
                    else if (!ConfigHelper.GetAppSetting<bool>(Constants.KEY_TORNADO_ENABLE_MARKETPLACE) && marketplace != null)
                    {
                        //REMOVE MARKETPLACE BUTTON
                        marketplace.ParentNode.RemoveChild(marketplace);
                        changed = true;
                    }
                    else if (ConfigHelper.GetAppSetting<bool>(Constants.KEY_TORNADO_ENABLE_MARKETPLACE)
                        && marketplace != null
                        && marketplace.Attributes["text"].Value == "Marketplace... (Beta)")
                    {
                        //REMOVE MARKETPLACE BETA STATUS
                        (marketplace as XmlElement).SetAttribute("text", "Marketplace...");
                        changed = true;
                    }
     
                    //ADD NEW SEND TO MARKETPLACE BUTTON IF APPLICABLE
                    var sendMarketplace = listActions.SelectSingleNode("menuItem[@name='SendMarketplace']");
                    if (ConfigHelper.GetAppSetting<bool>(Constants.KEY_TORNADO_ENABLE_MARKETPLACE) && sendMarketplace == null)
                    {
                        //CREATE ELEMENT FROM XML FOR ACTION ITEMS
                        var element = doc.CreateElement("menuItem");
                        element.SetAttribute("commandName", "sendMarketplace");
                        element.SetAttribute("commandButtonType", "Standard");
                        element.SetAttribute("isFilter", "False");
                        element.SetAttribute("cssClass", "sfViewOrg");
                        element.SetAttribute("text", "Send to Marketplace");
                        element.SetAttribute("wrapperTagKey", "Li");
                        element.SetAttribute("widgetType", "Telerik.Sitefinity.Web.UI.Backend.Elements.Widgets.CommandWidget, Telerik.Sitefinity");
                        element.SetAttribute("isSeparator", "False");
                        element.SetAttribute("name", "SendMarketplace");
                        element.SetAttribute("this", "urn:telerik:sitefinity:configuration:type", "Telerik.Sitefinity.Web.UI.Backend.Elements.Config.CommandWidgetElement, Telerik.Sitefinity");
     
                        //ADD TO EXISTING ACTION ITEMS
                        listActions.AppendChild(element);
                        changed = true;
                    }
     
                    //SAVE AND RESTART APP IF APPLICABLE
                    if (changed)
                    {
                        doc.Save(file);
     
                        //MANUALLY RESTART APP FOR CONFIG TO BE LOADED
                        RestartApplication();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //TODO: LOG ERROR
        }
    }
     
    /// <summary>
    /// Restarts the app.
    /// </summary>
    public static void RestartApplication()
    {
        //VALIDATE TO ENSURE NOT ALREADY RESTARTING
        if (SystemManager.Initializing)
            return;
     
        //RESTART THROUGH SITEFINITY
        SystemManager.RestartApplication(true, true);
    }
  18. Adam
    Adam avatar
    23 posts
    Registered:
    05 Apr 2013
    01 Jun 2013 in reply to Basem
    Link to this post
    Basem,

    This is exactly what I needed. It saved me a lot of time! Many thanks!
18 posts, 0 answered