Kentico 中的多对多关系

发布于 2024-10-20 23:53:19 字数 165 浏览 8 评论 0 原文

是否有关于如何构建基于多对多关系的 Kentico CMS 门户实施的最佳实践(即销售食品并有很大一部分菜谱的网站 - 每个产品都用于许多菜谱中,每个食谱都可以使用网站上出售的许多产品)?

Kentico 是否只是一个错误的工具来执行此操作,或者 Kentico 内部是否有解决方案来处理此类关系?

Are there any best practices on how to build a Kentico CMS Portal implementation which is based around a many-to-many relationship (i.e. a website which sells food product and has a large section with recipes -- each product is used in many recipes, each recipe can use many of the products sold on the site)?

Is Kentico simply the wrong tool to do this or are there solutions within Kentico to handle this kind of relationships?

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

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

发布评论

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

评论(6

|煩躁 2024-10-27 23:53:19

我会考虑内置的相关文档系统。在文档的属性选项卡下,有一个相关文档的部分。此处描述了该功能:

文档属性,相关文档

如果这是您网站的一项重要功能,您可以将该部分作为另一个选项卡添加到现有的“页面”、“设计”、“表单”、“属性”选项卡中,以便于访问。您只需要修改站点管理器 -> 的模块区域即可。发展。另请注意:从技术上讲,它们是单向关系,但您可以将查询构造为双向:

SELECT *
FROM CMS_Document d
JOIN CMS_Relationship r 
    ON (d.DocumentID = r.LeftNodeID
    OR d.DocumentID = r.RightNodeID)
Where DocumentID = 100

的代码将 CMS_Document 表连接到 CMS_Relationship 表,为您提供 ID 为 100 的 Document 的所有相关文档。

上面 在数据库的峰值中,相关文档的表结构非常简单:

Related Document Tables

因此,按照 McBeev 的建议,我将创建产品和食谱的自定义文档类型。然后您可以按照我上面概述的方式链接它们。祝你好运!

I would consider the built in Related Documents system. Under the properties tab on a document, there is a section for the related documents. The functionality is described here:

Document Properties, Related Docs

If this was a big piece of functionality for your website, you could probably add the section as another tab to the existing Page, Design, Form, Properties tabs for easier access. You would just need to modify the Modules area of Site Manager -> Development . Another heads up: they are technically unidirectional relationships, but you can structure your queries to go both ways:

SELECT *
FROM CMS_Document d
JOIN CMS_Relationship r 
    ON (d.DocumentID = r.LeftNodeID
    OR d.DocumentID = r.RightNodeID)
Where DocumentID = 100

The above code will join the CMS_Document table to the CMS_Relationship table to give you all the related documents for Document with ID 100.

If you take a peak at the database, the table structure for Related Documents is VERY simple:

Related Document Tables

So as McBeev suggested, I would create a custom document types for the products and the recipes. Then you can link them as I outlined above. Good luck!

以为你会在 2024-10-27 23:53:19

开箱即用的它不能很好地支持多对多,但是您应该能够通过一些自定义开发来做到这一点。创建 2 个自定义文档类型,例如食谱和产品,然后创建自定义表单控件来管理关系。然后,将表单控件放置在页面上,以便可以在节点的表单选项卡上管理字段。表单控件(如果您想从两种类型进行管理,则为 2)将是多对多类型控件,例如复选框列表或多选。然后在保存时,您将使用 API 或 SQL 代码保存到联接表而不是文档本身(或子文档类型)。您可能需要手动创建连接表。

http://www.kentico.com/docs/devguide/index.html ?developing_form_controls.htm

Out of the box it does not support many-to-many very well, however you should be able to do it with a bit of custom development. Create the 2 custom document type, such as Recipes and Products, then create a custom Form Control to manage the relationship. You then place the Form Control on the page so that the fields are managable on the Form tab of the node. The Form Control (or 2 if you want to manage from both types) would be a many-to-many type control such as a list of checkboxes or a multi-select. Then on saving you would use API or SQL code to save to the join table rather than the document itself (or child document type). You may need to create the join table manually.

http://www.kentico.com/docs/devguide/index.html?developing_form_controls.htm

挖鼻大婶 2024-10-27 23:53:19

使用自定义表并编写您自己的自定义 Web 部件将帮助您实现这些目标。

Using Custom Tables and writing your own custom webparts will help you a long way to accomplishing these goals.

梦屿孤独相伴 2024-10-27 23:53:19

您还可以为您的产品和食谱创建自定义文档类型,然后使用内置的链接到现有文档功能。

不过,我确实同意 dvanbale 的观点,您也可以使用自定义表格来完成此任务。

这确实取决于您到底想做什么。

You can also go a long way with creating custom Document Types for your Products and Recipes and then use the built in Link to an Existing Document functionality.

I do agree with dvanbale though, you could accomplish this as well with Custom Tables.

It kind of does depend on what you want to do exactly.

庆幸我还是我 2024-10-27 23:53:19

我已经遇到过几次这个问题,并想出了一个使用 sql 函数和 sql 重复器来快速解决内容树的父子层次结构的方法。它绝不是一个健壮的实现。如果这是您的迫切需要,我同意定制表格可能是最佳选择。

实际上,我刚刚发布了我所做工作的详细版本。我在搜索它是否已被索引时发现了这一点。您可以在这里看到它:

http://www.kenticosolutions.com/Developer-Tips/Tip/May-2011/Many-to-Many-relationships-in-the-Kentico-CMS-Cont.aspx

I've run into this a few times and came up with a quick work-around for the parent-child hierarchy of the content tree using a sql function and a sql repeater. By no means is it a robust implementation. If that was your immediate need, I would agree that custom tables is probably the way to go.

I actually just posted a detailed version of what I've done. I found this when I was searching to see if it was indexed. You can see it here:

http://www.kenticosolutions.com/Developer-Tips/Tip/May-2011/Many-to-Many-relationships-in-the-Kentico-CMS-Cont.aspx

很酷不放纵 2024-10-27 23:53:19

可以直接使用 kentico CMS 来执行此操作,而无需编写任何自定义代码或查询。

幸运的是,我写了一篇关于它的文章并成功实现了它,这为内容管理员提供了足够的灵活性来管理关系数据,而无需开发人员。

通过转发器获取相关内容

It is possible to do this directly using kentico CMS and without writing any custom code or query.

Luckily I wrote an article about it and have successfully implemented it which gives enough flexibility to content admin to manage relational data without the need of a developer.

Related Content through a repeater

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