0

Now that my new views start with

@inherits Custom.Hybrid.Razor12

What do I need to do to continue to get access to Dnn Stuff when needed? I've been bouncing around the docs, but haven't spotted anything yet.

Are there compile codes that will let us do things like <### IF DNN ###>?

My specific need right now, and I am hoping someone can offer an example, is we always wrapped our module/View output like this

<div id="viewtype-@(Dnn.Module.ModuleID)">

</div>

And this allowed us to include some very module-targeted (non-leaky) CSS.

<style>
#viewtype-@(Dnn.Module.ModuleID) .navbar{
  ...
}
</style>

So then this sort of becomes two questions:

  • How do you do DNN specific things in a View properly?
  • What is the new-correct way to do the thing in the example above so that it would ALSO work on Oqtane? Do they have a Helper that would provide a unique ID at the same level as the View?
Jeremy Farrance
  • 740
  • 6
  • 11
  • Okay, I found part of the answer here. https://docs.2sxc.org/api/dot-net/ToSic.Sxc.Context.ICmsModule.html But if I still needed/wanted to actually get use something from the @Dnn helper, is there a way to make that work? – Jeremy Farrance Dec 14 '21 at 19:02
  • 2
    Hi Jeremy - to get the Dnn object you must use the base class Custom.Dnn.Razor12 - it's only difference is the Dnn object. That cannot work on Hybrid, because Oqtane won't have a Dnn object - otherwise it's the same as Custom.Hybrid.Razor12 – iJungleBoy Dec 22 '21 at 06:41

1 Answers1

0

When you are editing a template, there is a menu at the left of the edit window. If you expand the <> you will see all sorts of helpers, DNN and otherwise.

And, the top icon expands to a list of all of the files/views/css that you might want to edit.

Or am I misunderstanding?

Oh, you don't have to do any of the <## xxxx ##> stuff any more. You can just refer to the DNN variables and methode (perhaps preceded by @) and just use them. After all, the template is a mixture of HTML and Razor stuff. The Razor stuff is darned close to c#.

So, you could drop something in like:

[p] This is an example of using the portal id: @Dnn.Module.PortalID [/p]

Note: < and > replaced by [ and ] so that they aren't interpreted as tags.

Joe Craig
  • 1,244
  • 1
  • 7
  • 7