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

Notification

Icon
Error

how to add setting value for module?
hyeongseong
#1 Posted : Monday, August 22, 2011 5:31:13 AM(UTC)
Rank: Member
Groups: Registered

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

I am just wondering if there is a way to add settings for module.
For example. by default, in module.config file.
There is a setting called ThemeName and "Default" is assigned to it.

I assume that it is from module.config and ScaffoldController.cs and modulesetting from meta data like below.

in module.config

<ThemeName>ThemeName</ThemeName>

in ScaffoldController.cs

private static void GenerateModuleInfo()
{
moduleInfo.DefaultSettings = new ModuleSettings()
{
ThemeName = "Default",
Entry = new Entry()
{
Controller = "Home",
Action = "Index"
}
};
}

/* modulesetting from meta data */

using System;
using System.Collections.Generic;

namespace Kooboo.CMS.Sites.Extension.Module
{
public class ModuleSettings
{
public ModuleSettings();

public Dictionary<string, string> CustomSettings { get; set; }
public Entry Entry { get; set; }
public string ThemeName { get; set; }
}
}


For modulesetting from meta data is ,I assume, dll file and I can't edit them. so is there no way to add a setting value for module?


jifeng
#2 Posted : Monday, August 22, 2011 6:07:22 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
The following code show you how to add some custom settings.

moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>();
moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1";
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
hyeongseong
#3 Posted : Monday, August 22, 2011 7:57:15 AM(UTC)
Rank: Member
Groups: Registered

Joined: 8/10/2011(UTC)
Posts: 12
private static void GenerateModuleInfo()
{
try
{
ModuleInfo moduleInfo = new ModuleInfo();

moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>();
moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1";



moduleInfo.ModuleName = "Sample";
moduleInfo.Version = "3.0.1.0";
moduleInfo.KoobooCMSVersion = "3.0.1.0";
moduleInfo.InstallUrl = "~/installer/install";
moduleInfo.UninstallUrl = "~/installer/uninstall";

moduleInfo.EntryOptions = new EntryOption[]{
new EntryOption(){ Name="NewsList",Entry = new Entry{ Controller="Home",Action ="Index"}},
new EntryOption(){ Name="NewsCategories",Entry = new Entry{ Controller="Home",Action ="Categories"}},
new EntryOption(){Name="ArticleCategories",Entry=new Entry{Controller="Article",Action="Categories"}},
new EntryOption(){Name="ArticleList",Entry=new Entry{Controller="Article",Action="List"}},
};
ModuleInfo.Save(moduleInfo);
}
catch (Exception e)
{
}
}


is that all I have to do? do i have to add something in some other files?

thx.
jifeng
#4 Posted : Monday, August 22, 2011 8:21:17 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
That is all!
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
hyeongseong
#5 Posted : Tuesday, August 23, 2011 12:08:55 AM(UTC)
Rank: Member
Groups: Registered

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

Just one more thing.

if I do like that in ScaffoldController.cs

private static void GenerateModuleInfo()
{
ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.ModuleName = "Sample";
moduleInfo.Version = "3.0.1.0";
moduleInfo.KoobooCMSVersion = "3.0.1.0";
moduleInfo.InstallUrl = "~/installer/install";
moduleInfo.UninstallUrl = "~/installer/uninstall";
moduleInfo.DefaultSettings = new ModuleSettings()
{
ThemeName = "Default",
Entry = new Entry()
{
Controller = "Home",
Action = "Index"
}
};

moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>();
moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1";
moduleInfo.DefaultSettings.CustomSettings["Setting2"] = "Value2";
moduleInfo.DefaultSettings.CustomSettings["Setting3"] = "Value3";

moduleInfo.EntryOptions = new EntryOption[]{
new EntryOption(){ Name="NewsList",Entry = new Entry{ Controller="Home",Action ="Index"}},
new EntryOption(){ Name="NewsCategories",Entry = new Entry{ Controller="Home",Action ="Categories"}},
new EntryOption(){Name="ArticleCategories",Entry=new Entry{Controller="Article",Action="Categories"}},
new EntryOption(){Name="ArticleList",Entry=new Entry{Controller="Article",Action="List"}},
};
ModuleInfo.Save(moduleInfo);
}
}


How do I have to display setting on Settings page? How should I add the code below in Settings.cshtml?
Thx.

<div class="tab-content" id="settingsInfo">
@Html.ModuleHtml().EditorFor(m => m.Settings)
</div>



hyeongseong
#6 Posted : Tuesday, August 23, 2011 1:03:32 AM(UTC)
Rank: Member
Groups: Registered

Joined: 8/10/2011(UTC)
Posts: 12
Would you be able to provide useful matrials for understanding module sourse code?

Thx.
jifeng
#7 Posted : Tuesday, August 23, 2011 2:56:24 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
It required you have some ASP.NET MVC skill here, you have to create the editor templates for the model.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
hyeongseong
#8 Posted : Tuesday, August 23, 2011 4:02:10 AM(UTC)
Rank: Member
Groups: Registered

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

if I add setting like that in ScaffoldController.cs

private static void GenerateModuleInfo()
{
ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.ModuleName = "Sample";
moduleInfo.Version = "3.0.1.0";
moduleInfo.KoobooCMSVersion = "3.0.1.0";
moduleInfo.InstallUrl = "~/installer/install";
moduleInfo.UninstallUrl = "~/installer/uninstall";
moduleInfo.DefaultSettings = new ModuleSettings()
{
ThemeName = "Default",
Entry = new Entry()
{
Controller = "Home",
Action = "Index"
}
};

moduleInfo.DefaultSettings.CustomSettings = new Dictionary<string, string>();
moduleInfo.DefaultSettings.CustomSettings["Setting1"] = "Value1";
moduleInfo.DefaultSettings.CustomSettings["Setting2"] = "Value2";
moduleInfo.DefaultSettings.CustomSettings["Setting3"] = "Value3";

moduleInfo.EntryOptions = new EntryOption[]{
new EntryOption(){ Name="NewsList",Entry = new Entry{ Controller="Home",Action ="Index"}},
new EntryOption(){ Name="NewsCategories",Entry = new Entry{ Controller="Home",Action ="Categories"}},
new EntryOption(){Name="ArticleCategories",Entry=new Entry{Controller="Article",Action="Categories"}},
new EntryOption(){Name="ArticleList",Entry=new Entry{Controller="Article",Action="List"}},
};
ModuleInfo.Save(moduleInfo);
}
}


How do I have to display setting on Settings(ie Setting1,Setting2,Setting3) page and be able to modify the value? How should I add the code below in Settings.cshtml?
Thx.

<div class="tab-content" id="settingsInfo">
@Html.ModuleHtml().EditorFor(m => m.Settings)
</div>
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.138 seconds.