DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

API code blocks - Master Theme file?

 4 Replies
 0 Subscribed to this topic
 13 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 6
New Around Here

    Hello again DNN Community! 

    I have a custom theme (more on this below) with layouts that use code blocks referencing the DNN API. I'd like to centralize these code blocks since I apply them across all of the layouts. 

    Code examples:

    And 

    <% If Not DotNetNuke.Security.PortalSecurity.IsInRole("Administrators") Then %>

    Instead of applying this logic/code in each layout, I'd like to stick them in a "master" file that can be referenced in each layout. This makes potential changes in the future much easier to implement since I'll just need to update one file instead of each individual layout. I'd also be open to applying something like this Portal-wide, but I'm not quite sure how to implement that either. 

    Additional backstory: The custom theme I'm using started from a simple copy of the default Xcillion skin/theme. I've often ran into 500 errors when trying to implement solutions for my predicament. I'm concerned that maybe it stems from me creating my current theme from a copy, instead of building it out as a DNN Theme in Visual Studio from scratch. 

    Appreciate your expertise and help!

    Advanced Member
    Posts: 232
    Advanced Member
      You can technically have an assembly (.dll) with your theme, you just need to compile it and declare it in your manifest for installation. There you can have all kinds of reusable functions which can also include controls you can reuse. It is not technically wrong to copy the default theme, just make sure to change the folder names and if packaging to change all unique names in the manifest too. My preference is to start from scratch though, Xcillion is not the most modern. If you want something more documented there are other theme templates around that are better suited to start a new theme:

      https://www.nvquicktheme.com/
      Very popular and nicely documented

      https://github.com/eraware/Eraware.MinimalSkin
      My own very minimal one, focuses on build/automation but is very barebone.

      Veteran Member
      Posts: 342
      Veteran Member
        In the nvQuickTheme repo, you will see an example of how you could dynamically load "partial" layouts based on the desired custom logic.

        https://github.com/nvisio...develop/default.ascx

        While the above does not have the custom logic, I think you have that part figured out. ;-)

        Hopefully this concept of "partial" layouts helps you out.

        David Poindexter


        Creator:


        New Around Here
        Posts: 6
        New Around Here
          This is really helpful -- I'll look into both of these themes.

          Thank you Daniel and David!


          Veteran Member
          Posts: 342
          Veteran Member
            You are most welcome!

            David Poindexter


            Creator:


            These Forums are dedicated to the discussion of DNN Platform.

            For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

            1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
            2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
            3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
            4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
            5. No Flaming or Trolling.
            6. No Profanity, Racism, or Prejudice.
            7. Site Moderators have the final word on approving / removing a thread or post or comment.
            8. English language posting only, please.

            Would you like to help us?

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

            Get Involved