PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 24, 2022

[FIXED] How do I determine pages that contain layouts with content-item of certain entity object in DNN module 2sxc programmatically?

 August 24, 2022     2sxc, dotnetnuke, module     No comments   

Issue

I have entity ListSettings which is used as Content-Item type for 2 layouts. Each layout is used 3 times on different pages. The code I'm writing is not executed on the page - it's outside of 2sxc module. So I wan't to find out on which page each object of entity ListSettings is. TabId is the best. Filtering by layout could be helpful as well since I need 3 tabIds that use 1 of the 2 layouts. How do I do that programmatically? There's a lot of data inside of each entity including some relationships, children, parents and so on. Also I'm sure that all this data could be taken from the database manually, but it seems to be a hard way for me.

Bottom line: I have 6 entities. I want to get their tabIds and layouts programmatically. Layouts are optional but would be good. Any suggestions?


Solution

This is quite challenging, because there are so many steps involved. But you can find something that does something similar here https://2sxc.org/dnn-tutorials/en/razor/2sa110/page

Here is an excerpt of the code:


  // CONSTANTS
  // this key is used in module settings
  const string SettingsCG = "ToSIC_SexyContent_ContentGroupGuid";

  // create array with all 2sxc modules in this portal
  List<ModuleInfo> GetAllModulesOfPortal(int portalId) {
    var mc = ModuleController.Instance;
    var dnnMod2sxcContent = mc.GetModulesByDefinition(portalId, "2Sexy Content");
    var dnnMod2sxcApp = mc.GetModulesByDefinition(portalId, "2Sexy Content App");
    var mergedMods = new ModuleInfo[dnnMod2sxcContent.Count + dnnMod2sxcApp.Count];
    dnnMod2sxcContent.CopyTo(mergedMods);
    dnnMod2sxcApp.CopyTo(mergedMods, dnnMod2sxcContent.Count);
    var allMods = mergedMods
      .Where(m => m.DefaultLanguageModule == null)
      .Where(m => !m.IsDeleted)
      .Where(m => m.ModuleSettings.ContainsKey(SettingsCG));
    return allMods.ToList();
  }



Answered By - iJungleBoy
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing