Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesModule to inject html/js code in page with config optionModule to inject html/js code in page with config option
Previous
 
Next
New Post
5/8/2014 9:07 AM
 

I'm looking to use a module to display a snippet of HTML/JS into a webpage similar to Google Analytics code. (This I have already achieved but with a hardcoded parameter)

I would like to configure the parameter within the module page settings itself OR in an admin view.  

Edit mode:

Set ID here [ 123456 ]  [UPDATE]

 Website view:

<div class="display_123456">

  <script src=http://domain.com/display.aspx?id=123456>

</div>

Ideally the module could be placed in several pages or even across several portals with different parameters on each instance.

 Any assistance or pointers would be gratefully appreciated.

 
New Post
5/9/2014 6:46 AM
 
Eventually worked this out.

Quite a few steps to do it "properly" which aren't all seemingly documented in the same place.
 
New Post
5/9/2014 6:51 AM
 
Hi Mike,

Can you share those steps? I'm sure others would find it useful.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
7/28/2014 9:45 AM
 
In settings.ascx to set a variable, use the folloiwng code to update a module setting:

ModuleController modules = new ModuleController();

modules.UpdateTabModuleSetting(TabModuleId, "Setting1", txtSetting1.Text);

Then in view.aspx call it back into a variable:

string Setting1 = base.Settings["Setting1"].ToString();

Don't forget to add using DotNetNuke.Entities.Modules;

There's a working example on Github https://github.com/Cumbria/DNN_Sample...
 
New Post
7/28/2014 10:32 AM
 

I was editing this but it wouldn't let me submit the changes... perhaps I timed-out? Anyway, here's the updated version with more information. Perhaps a moderator could maybe remove the prior post?

Building

In settings.ascx to set a variable, use the following code to update a module setting:

  ModuleController modules = new ModuleController();

  modules.UpdateTabModuleSetting(TabModuleId, "Setting1", txtSetting1.Text);


Then in view.aspx call it back into a variable:

  string Setting1 = base.Settings["Setting1"].ToString();

Don't forget to add using DotNetNuke.Entities.Modules;

There's a working example on Github https://github.com/Cumbria/DNN_Sample...

Deployment

Once you have the code in place, go back into the module definition and add a module control for the settings. Essential fields are as follows:

Key: Settings

Source: DesktopModules\Organisation\Module\Settings.ascx

Type: Edit

When you deploy the module you should be able to access the settings tab in edit mode and add your variable.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesModule to inject html/js code in page with config optionModule to inject html/js code in page with config option


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

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

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. 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.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out