Skip Navigation

How to inject 2sxc apps into a DNN theme and why you would want to do that

Posted in DNN, How To, Video on June 8, 2022

In this super quick video, I show you how to inject 2sxc apps into your DNN theme.

I first used this feature because I wanted to build a mega-menu on a DNN website that the customer could edit easily themselves but I didn't want the overhead of having to manage the app on every page it gets added to.

If you're wanting to both provide the best content editor experience you can for your customers, but also make your life as a developer easier, then check out this 6 minute video:

If you just want the solution and the code, here it is:

  1. Create an app on a hidden page (not visible by users)
  2. Take note of the Page ID and Module ID
  3. Include the code below into your theme. The first two lines are register tags that you only need once. The third line is the actual line that gets the module so you put that wherever you want the module to exist.

<%@ Import Namespace="DotNetNuke.Entities.Modules" %>
<%@ Import Namespace="ToSic.Sxc.Dnn" %>
<%@ Import Namespace="ToSic.Sxc.Services" %>
 <%
    var moduleController = new ModuleController();
    ModuleInfo footerModule = moduleController.GetModule(39, 394);
    if (footerModule != null) {
  %>
    <%= this.GetScopedService<IRenderService>().Module(39, 394) %>
  <%
    }
  %>

Note: David Poindexter provided an update to the above code above to make it less brittle. The code in the theme now checks if the module exists so it doesn't break the theme if it fails.

The first number ("39") is your page ID. You can find that under Page Settings. The second number ("394") is the module ID.

Big shoutout to Daniel Mettler for this feature but also Jeremy Farrance of Accuraty for chatting with me about the new implementation!

It's that easy! I hope you find ways to integrate this into your websites. If you ever need help with stuff like this, please reach out to me at aaron.lopez@wolfxmachina.com

Aaron Lopez

Aaron Lopez

Founder & Lead Developer at Wolf X Machina

See what we can do for you

Our Services

Wolf X Machina Interface Development logo

Wolf X Machina is a team of developers and designers located in Victoria, BC and Saskatoon, SK. We've completed projects for very recognizable brands and our work is used by hundreds of thousands of people around the world.