module settings

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/21/2010 3:13:19 AM
Gravatar
Total Posts 8

module settings

hiya, im trying to use the module settings feature but am completely lost.

any chance you have a hello world sample for how to setup a module and store a value in the module settings ?

1/21/2010 7:55:32 AM
Gravatar
Total Posts 190

Re: module settings

I'd first read thoroughly through this section: http://www.mojoportal.com/addingfeatures.aspx What I found helpful was to look at the properties of existing features how they are set up in the admin. The files in the setup folder also allow you to create install scripts that will set up all the feature settings options for you. It's worthwhile looking through those as well.

1/21/2010 3:44:27 PM
Gravatar
Total Posts 18439

Re: module settings

You must first define the settings for your feature. After you install your feature as described in the hello world article, you can then define settings and set default values from the UI at Administration > Advanced Tools > Feature Installation/Configuration > Your Feature > Settings.

Once the setting is defined, then there is already a UI to set the instance specific values. If you have 

<portal:ModuleTitleControl EditText="Edit" runat="server" id="TitleControl" /> in your Feature then when you put it on a page you will see a link for "Settings" and if you click it you will see where you can set the setting you defined on your feature.

So you don't really need to set settings from inside your feature there is already a page to set them, you can use them in your feature, ie read theior values like this snippet from the Google Maps feature I told you to look at:

if (Settings.Contains("GoogleMapInitialMapTypeSetting"))
            {
                string gmType = Settings["GoogleMapInitialMapTypeSetting"].ToString();
                try
                {
                    mapType = (MapType)Enum.Parse(typeof(MapType), gmType);
                }
                catch (ArgumentException) { }

            }

As I said before "Settings" is intrinsic to SiteModuleControl, it is already there for you.

There are also helper methods to convert values in Settings to specific types like:

useLocationAsCaption = WebUtils.ParseBoolFromHashtable(
                Settings, "GoogleMapShowLocationCaptionSetting", useLocationAsCaption);

            mapHeight = WebUtils.ParseInt32FromHashtable(
                Settings, "GoogleMapHeightSetting", 300);

Where you can pass in a default value in case it is not found in the settings, that is what the 3rd parameter is in these methods.

Hope it helps,

Joe

 

You must sign in to post in the forums. This thread is closed to new posts.