如何通过编程方式确定包含某些实体对象的内容的布局的页面?

发布于 2025-02-05 03:00:34 字数 324 浏览 2 评论 0原文

我有实体listSettings,用作2个布局的内容 - 项目类型。每个布局在不同页面上使用3次。 我编写的代码未在页面上执行 - 它在2SXC模块之外。 因此,我不会在哪个页面上找到实体ListSettings的每个对象。 Tabid是最好的。通过布局过滤也可能会有所帮助,因为我需要3个使用2个布局中的1个标签。 我该如何编程?每个实体内部有很多数据,包括一些关系,孩子,父母等。我也确定所有这些数据都可以手动从数据库中获取,但这对我来说似乎是一个困难的方法。

底线:我有6个实体。我想以编程方式获取他们的标签和布局。布局是可选的,但很好。 有什么建议吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2025-02-12 03:00:34

这很具有挑战性,因为涉及太多步骤。但是您可以在此处找到类似的事情 https:/ DNN-Tutorials/en/razor/2sa110/page

这是代码的摘录:


  // 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();
  }

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();
  }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文