Module Builder - DynamicModulesConfig.config
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,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.
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".
As for the 2nd question, I've tried it both way. Both ways give the same result.
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?
If I edit the module from the Module Builder after doing these edits to the DynamicModuleConfig.config, the DynamicModuleConfig.config.
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;
If I edit the module from the Module Builder after doing these edits to the DynamicModuleConfig.config, the DynamicModuleConfig.config.
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;
Any update on this? Telerik.Sitefinity.DynamicModules.Configuration.DynamicModulesConfig is marked as an internal class. Is there another way to modify DynamicModulesConfig.config programmatically?
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
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
Adam,
From the developers community in google. Steve posted this link:
www.sitefinity.com/.../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.
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...
No. Scroll down to "To modify values from PageAppearanceConfig.config, use the following code:"
But instead you would modify DynamicModulesConfig.config
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.
Technically, you can't, but you can write your own (use JustDecompile).
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
);
Basem,
This is exactly what I needed. It saved me a lot of time! Many thanks!