2sic / 2sxc

DNN + 2sxc = #DNNCMS - This tool helps web designers and developers prepare great looking content in DNN (DotNetNuke). It's like mixing DNN with Umbraco and Drupal :)
http://2sxc.org
MIT License
145 stars 40 forks source link

Feat: Enable 2sxc Modules in Skin to also register js/css assets #2919

Closed iJungleboy closed 1 year ago

iJungleboy commented 1 year ago

I'm submitting a ... [x] bug report => search github for a similar issue before submitting [x] feature request

...about [x] Razor templating [x] DNN parts

Current behavior

When including a 2sxc module in the theme using the IRenderService, it does not auto-include the JS/CSS assets in the page.

But it should...

fixed in 9e508ad056972c65f9f8035265b5b5f91610d19b and d0d70c568eedbbe10661a57c261e259c8d65e8a3

Your environment

iJungleboy commented 1 year ago

@tvatavuk I haven't documented this yet, and I forgot what must be done :) could you quickly post your findings here, so that I'll add them to the official docs later?

tvatavuk commented 1 year ago

Our custom c# code has to be executed in the page .OnPreRender event. Here is example of code, that can be used in skin ascx.

<script runat="server">
  public IRenderResult Data;
  protected override void OnPreRender(EventArgs e)  {
    base.OnPreRender(e);
    Data = this.GetScopedService<ToSic.Sxc.Services.IRenderService>().Module(1494, 2563);
  }
</script>
<%= Data %>
iJungleboy commented 1 year ago

thx!

iJungleboy commented 1 year ago

documented on https://docs.2sxc.org/net-code/platform-api/dnn/themes-modules.html