DNN Forums

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

Using managed content in content generated by JS framework

Sort:
You are not authorized to post a reply.





New Around Here





    I use a custom DNN module which with a tabbed bootstrap navigation inside. It was build with Knockout-JS. Now I want to add some pieces of content inside this module, e.g. one html control per navigation tab and some explainatory popovers. I would like to manage that content with DNN if somehow possible.

    One possibilty would be to use DNN headless and have my module read the content from DNN. Don't know if this is possible at all.

    I am thankful for any ideas about this!






    Veteran Member





      do you want content per item? in this case you should store it in your module, using either same data source or a table inside the DNN database. Where should the content be edited?





      New Around Here





        Naively I was thinking about placing a number of html modules on an edit-only page and then import that content (the html content) via a javascript function. I am aware that this does not sound like a plan. Maybe I should add the content to the page (just under my costum module), edit the content there, hide it via css and copy the content into my knockout construct at runtime. I was hoping there is a more elegant solution without employing an actual (additional) headless CMS.






        Growing Member





          Hi Tim,

          Your opening sentence was 'I use a custom DNN module...' but for this to work you probably need to be the developer of the module. For now I will assume that is the case ;-)

          Your idea about placing a number of text editors in an edit-view does not sound like a bad idea at all, although I would probably use the settings-view instead. The CK-Editor can be used as far as I recall to allow you to edit the text without concern of html tags etc. but if that is a pain to use other options could be included in your module instead, such as TinyMCE or similar.

          Add the required number of editors to your settings-view and store the text in the TabModuleSettings. The texts can be loaded again in the view and placed in the page in a script section to gain access to it from javascript if that is your weapon of choice.

          // SETTINGS FILE CODEBEHIND
          modules.UpdateTabModuleSetting(TabModuleId, "Setting1", myEditor1.Text);

          Loading the data in the codebehind of the view module is just as easy as getting the data from an array.

          // VIEW FILE CODEBEHND
          public string MyFirstText { get; private set; }
          // PageLoad
          if (Settings.ContainsKey("Setting1"))
          {
            this.MyFirstText = Settings["Setting1"].ToString();
          }

          // VIEW FILE
          <script>
          var myFirstText = '<%= MyFirstText %>';
          </script>

          See the Chris Hammond template to build a module for more details on how to add data in your module from the settings view.

          If you are not the developer things will soon become overcomplicated when adding html-modules and keeping track of them and their IDs in your page, so let's hope that is not the case ;-)

          # DnnBro






          New Around Here





            Thank you, DnnBro! I am using Chris Hammonds templates (an age old version) and tried your suggestion with just one Setting. Will totally do for the content pieces in my control! I remember now having used settings for content... but that was about 10 years ago. I can probably expand on your idea a bit and use a collection of settings so I can add new stuff without having to recompile / restart the site.






            Growing Member





              Glad I could help :-)

              #DnnBro
              You are not authorized to post a reply.

              These Forums are dedicated to the 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 instead follow the official DNN security policy
              2. No Advertising. This includes the 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