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" %>

    <%= this.GetScopedService<IRenderService>().Module(39, 394) %>
 

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

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.