module/feature 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.
10/17/2010 3:46:17 AM
Gravatar
Total Posts 14

module/feature settings

Hi all,

It seems to be rather odd that when I am adding new feature settings in the featureDefinitions file and run the setup/default.aspx, the new setting did not gets added to the database. I can see it by inspecting the Settings object in debug mode.

The old settings can be updated successfully. But I could not figure how to added a new one.

Thanks in advance.

Derek Liang

 

<?xml version="1.0" encoding="utf-8" ?>
<featureDefinitions>
    <featureDefinition
        featureGuid="A8DDE31E-D80E-11DF-AC83-4F18DFD72085"
        supportedDatabases="MSSQL"
        resourceFile="Resources"
        featureNameReasourceKey="PropertyList"
        controlSource="xxx/Property.ascx"
        sortOrder="100"
        isCacheable="true"
        defaultCacheTime="0"
        excludeFromFeatureList="false"
        isSearchable="false"
        searchListNameResourceKey=""
        deleteProvider=""
        icon="blank.gif"
        >

        <featureSetting
        resourceFile="Resources"
        resourceKey="PageSizeSetting"
        defaultValue="5"
        controlType="TextBox"
        sortOrder="100"
        helpKey="PageSizeSettingHelp"
        regexValidationExpression="^[1-9][0-9]{0,4}$"
            />

        <featureSetting
            resourceFile="Resources"
            resourceKey="regexMLSNoSetting"
            defaultValue="MLS# (V\\d+),1"
            controlType="TextBox"
            sortOrder="110"
            />
...

10/17/2010 7:35:58 AM
Gravatar
Total Posts 18439

Re: module/feature settings

It should both update and add settings as long as the featureguid matches. 

possibly something about the value of your default could be a factor, experiment and see if it works when you change it to something more simple without \\ chars, maybe that breaks xml parsing or something. Are there any errors in your log after running setup page?

10/17/2010 1:25:58 PM
Gravatar
Total Posts 14

Re: module/feature settings

Hi Joe,

I traced the program and find out that:

1. ModuleDefinitionSettings table has updated according to the featureDefinitions file.

2. ModuleSetting table is not updated.

3. when the user control requesting the Setting object, it is loaded from ModuleSetting table which only contains previous setting (not the updated one defined in the featureDefinitions file)

I am not sure if there is a simple solutions, but here is the code that I came up and was tested working:

SiteModuleControl.cs

        public Hashtable Settings
        {
            get
            {
                if (settings == null)
                {
                    settings = ModuleSettings.GetModuleSettings(ModuleId);
                    int moduleDefId = GetModule(ModuleId).ModuleDefId;
                    ArrayList defaultSettingList = ModuleSettings.GetDefaultSettings(moduleDefId);

                    foreach (CustomModuleSetting defaultSetting in defaultSettingList)
                    {
                        if (!settings.ContainsKey(defaultSetting.SettingName))
                        {
                            settings.Add(defaultSetting.SettingName, defaultSetting.SettingValue);
                        }
                    }

                }
                return settings;
            }
        }

        private Module GetModule(int moduleId)
        {
            if (currentPage == null) { return null; }

            foreach (Module m in currentPage.Modules)
            {
                if (m.ModuleId == moduleId) { return m; }
            }

            return null;
        }

 

 

10/17/2010 7:47:33 PM
Gravatar
Total Posts 14

Re: module/feature settings

I think a better way is to use the following sql script after all default feature settings are imported. Since it only runs once while running setup/default.aspx. And it should fix any missing settings in the table.

Cheers,

Derek Liang

declare cur cursor for select DISTINCT  ModuleID from mp_ModuleSettings
declare @ModuleID int

open cur

fetch next from cur into @ModuleID

while @@fetch_status = 0
begin
    insert mp_ModuleSettings
        select
        m.ModuleID ModuleID,
        mds.SettingName,  
        mds.SettingValue,
        mds.ControlType,
        mds.RegexValidationExpression,
       NEWID() [SettingGuid],
        ms.ModuleGuid,
        mds.ControlSrc,
        mds.SortOrder,
        mds.HelpKey

        from mp_ModuleDefinitionSettings mds, mp_Modules m, mp_ModuleSettings ms
        where mds.ModuleDefID=m.ModuleDefID and m.ModuleID=ms.ModuleID and
               m.ModuleID=@ModuleID  and (mds.SettingName not in(select SettingName from
                                            mp_ModuleSettings where ModuleID=@ModuleID))


    fetch next from cur into @ModuleID
end

close cur
deallocate cur
 

10/17/2010 11:55:22 PM
Gravatar
Total Posts 14

Re: module/feature settings

A easy to read version. :)

declare cur cursor for select ModuleID from mp_Modules
declare @ModuleID int
declare @ModuleGuid uniqueidentifier

open cur

fetch next from cur into @ModuleID

while @@fetch_status = 0
begin

set @ModuleGuid = (select [Guid] from mp_Modules where ModuleID=@ModuleID)

insert mp_ModuleSettings
select
        @ModuleID ModuleID,
        SettingName, 
        SettingValue,
        ControlType,
        RegexValidationExpression,
       NEWID() SettingGuid,
        @ModuleGuid ModuleGuid,
        ControlSrc,
        SortOrder,
        HelpKey

from    mp_ModuleDefinitionSettings
        where  (ModuleDefID = (select ModuleDefID from mp_Modules where ModuleID=@ModuleID))
                and
              (SettingName not in(select SettingName from mp_ModuleSettings where ModuleID=@ModuleID))

    fetch next from cur into @ModuleID
end

close cur
deallocate cur

10/18/2010 5:51:43 AM
Gravatar
Total Posts 18439

Re: module/feature settings

Hi Derek,

The Setup page is not supposed to update existing feature instance settings, only default settings. Default settings are used when a new instance of a feature is created but can then be customized on the instance.

In the module settings page it will still show the new settings and if you save it it will update the instance setting.

If a new settings is added but the user has not yet saved module settings again for the instance, the feature code should use the default value if the instance module settings does not contain the setting. 

Hope that helps,

Joe

11/10/2010 9:03:38 AM
Gravatar
Total Posts 13

Re: module/feature settings

help please, I have a user control consisting of a EventCalendar, two GridView, two DropDownList and a ModalPopup. The fact is that the ModalPopup GridView and make use of a Theme of the project, which works fine but do not know how to integrate the web.

Greetings from Lima - Peru

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