• Login
  • Register

DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Module developing

You are not authorized to post a reply.

New Around Here

New Around Here

    Hi, I want to develop a module that needs a setting in PortalSettings table. In the installing script I want to insert the row but how can I specify the current PortalId in which the module is being installing?

    Thanks in advance.

    Veteran Member

    Veteran Member

      When a module is installed or upgraded, there is no reference to a portal. So I'm not sure that you can do something like this.

      What is the use case here?
      Joe Craig
      DNN MVP
      Patapsco Research Group

      Growing Member

      Growing Member

        As Joe states there is no 'current' portal when installing a module - but if you 'just' need a valid portal id you can fetch the first available. Fill in the rest of the fields as needed - and remember to take the database scheme into consideration (the curly brackets part).

        INSERT INTO {YourDatabase}.{dbo}.[PortalSettings]
                   ((SELECT TOP (1) [PortalID] FROM {YourDatabase}.{dbo}.[Portals] ORDER BY [PortalID])
                   ,@SettingName, nvarchar(50),
                   ,@SettingValue, nvarchar(max),
                   ,@CreatedByUserID, int,
                   ,@CreatedOnDate, datetime,
                   ,@LastModifiedByUserID, int,
                   ,@LastModifiedOnDate, datetime,
                   ,@CultureCode, nvarchar(10),
                   ,@IsSecure, bit,)


        New Around Here

        New Around Here

          Hi Joe,

          thanks for the answer. I wanted to give an initialize value to a portalsettings for my module, but, if I have no references to the current Portal, I can do what DnnBro suggested.


          Veteran Member

          Veteran Member

            I would just do something like

            // This is pseudocode, not c#!
            protected string DefaultValueForMyModule {
               get {
                  object o = PortalController.GetPortalSetting(PortalId, "DefaultValueForMyModule");
                  if (o == null) {
                     return "DefaultValue";
                  return o.ToString();

            Happy DNNing!


            Michael Tobisch

            dnnWerk Austria
            DNN Connect

            New Around Here

            New Around Here

              try this.portalid you will get the portal id for the current DNN running portal.
              3ART TechnologiesRegards,
              3ART Technologies Expert

              3ART Technologies
              Experts in Analysis, Design & Development for DNN and SharePoint Solution

              Veteran Member

              Veteran Member

                You can use a technique like this:  


                You should just be aware that DNN instances that contain thousands of portals exist.  Anytime this is the case, such a technique might not be the best way to do this.  

                Will Strohl

                Upendo Ventures DNN experts since 2003
                Official provider of the DNN-based E-Commerce w/ Hotcakes Commerce Cloud and SLA support
                You are not authorized to post a reply.

                These Forums are dedicated to discussion of DNN Platform.

                For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

                1. If you have (suspected) security issues, please do not post them in the forums but send an email to [email protected]
                2. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
                3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
                4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
                5. No Flaming or Trolling.
                6. No Profanity, Racism, or Prejudice.
                7. Site Moderators have the final word on approving / removing a thread or post or comment.
                8. English language posting only, please.

                Would you like to help us?

                Awesome! Simply post in the forums using the link below and we'll get you started.

                Get Involved