Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Question about module.config and scaffoldController
hyeongseong
#1 Posted : Thursday, September 08, 2011 6:46:20 AM(UTC)
Rank: Member
Groups: Registered

Joined: 8/10/2011(UTC)
Posts: 12
Hi

I am working on module. I've got a few qustions about module.config file being generated.

In kooboo module development guide. it says.

"ScaffoldController is used to simulate the Kooboo CMS working environment. It will also generate the module.config file during execution. Module.config contains important information of the module like entry pages options, module installer and uninstaller location. You can modify the module.config manually after it is generated."

I just wondering when scaffoldController generates the module.config file after I upload a module to my kooboo website.



in order to access the module customersetting value, it seems like I have to do like.
ModuleInfo moduleInfo = ModuleInfo.Get("moduleName");

but It seems that it gets module setting values from module.config file.
and module.config file is never changed even I save or update module settings.

Could anyone explains how to save customerSetting value or access to it after update module settings?

Thx.
jifeng
#2 Posted : Friday, September 09, 2011 5:45:44 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
HI

The every sites can keep individual module setting. you can use SaveModuleSetting / GetSiteModuleSettings to store/get the module setting for site.

Code:


       public static void SaveModuleSetting(string moduleName, string siteName, ModuleSettings moduleSettings)
        {
            var siteModuleSettingFile = GetSiteModuleSettingFile(moduleName, siteName);

            DataContractSerializationHelper.Serialize(moduleSettings, siteModuleSettingFile);
        }
        private static string GetSiteModuleSettingFile(string moduleName, string siteName)
        {
            Site site = new Site(siteName);
            var siteModulesPath = Path.Combine(site.PhysicalPath, "Modules");
            var siteModuleNamePath = Path.Combine(siteModulesPath, moduleName);
            var siteModuleSettingFile = Path.Combine(siteModulesPath, "settings.config");
            return siteModuleSettingFile;
        }
        public static ModuleSettings GetSiteModuleSettings(string moduleName, string siteName)
        {
            if (!string.IsNullOrEmpty(siteName))
            {
                var siteModuleSettingFile = GetSiteModuleSettingFile(moduleName, siteName);

                if (File.Exists(siteModuleSettingFile))
                {
                    return DataContractSerializationHelper.Deserialize<ModuleSettings>(siteModuleSettingFile);
                }
            }
            return Get(moduleName).DefaultSettings;
        }

Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Armand
#3 Posted : Friday, September 23, 2011 1:17:50 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 7/18/2011(UTC)
Posts: 79
Location: UK
Hi,

Another question in connection with the module.config and settings.config: If I get it right, if the sitename parameter is not empty, then the function returns the settings.config from the given site. But when I try to put in some CustomSetting, eg. a DefaultUser, after having built it in the Settings.cshtml, it seems that the controller clears it out when it executes the SaveModuleSetting method. Is it possible to do it without rewriting the AdminController or writing another class?

Some more context:
At the moment I have this custom setting in the settings.config:

Code:

<a:KeyValueOfstringstring>
  <a:Key>DefaultUser</a:Key>
  <a:Value>Jake Plaster</a:Value>
</a:KeyValueOfstringstring>


I can query this in the View with

Code:
@Model.Settings.CustomSettings["DefaultUser"]


But when I change the value and save the settings page it comes up with the error:
The given key was not present in the dictionary.
and simply deletes the custom setting from the config file.

Is there a suggestion?

Thanks.
jifeng
#4 Posted : Saturday, September 24, 2011 9:33:45 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
I do not know where you changes will get this error. Do you mean you store the custom settings in the site?
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Armand
#5 Posted : Monday, September 26, 2011 8:07:57 AM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 7/18/2011(UTC)
Posts: 79
Location: UK
Hi,

Sorry, I might have forgotten to say that this is when I build a module and try to give it some custom settings (like default author) to appear in the sidebar Setting option (which apparently stores the settings in either settings.config or module.config depending on the site specification).

So I put the lines above in the config file manually, and I can read them in the View with the ModuleInfo().Settings.CustomSettings["whatever"], but when the View (Settings.cshtml) is getting passed back to the AdminController, it saves the Settings, but it seems it ignores the CustomSettings I pass in in the view.

Should I include these custom setting variables in the ModuleInfo_Metadata class in order to be able to save them back in the settings.config file?

Thanks.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.088 seconds.