• Login
  • Register

DNN Blogs

Written for the Community, by the Community

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

Written By Aaron Lopez
2022-06-09

This is crossposted from my blog at Wolf X Machina: https://wolfxmachina.com/blog/category/video/how-to-inject-2sxc-apps-into-a-dnn-theme-and-why-you-would-want-to-do-that

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 whereever you want the module to exist.

<%@ Import Namespace="ToSic.Sxc.Dnn" %>
<%@ Import Namespace="ToSic.Sxc.Services" %>
<%= this.GetScopedService().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.

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

More about Wolf X Machina Read more posts by Aaron

Total: 0 Comment(s)

Would you like to help us?

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

Get Involved