Sitecore 中使用自定义数据提供程序的 DropLink 数据源项参考
如何使用自定义数据提供程序绑定 DropLink?
更多信息: 我正在尝试使用 Sitecore 构建一个产品目录网站。 Sitecore 内容树中的每个产品都可以附加一个星级评定和简短的文本评论(它将链接到使用配置文件提供程序扩展的用户,但这是另一个问题)。
我计划将评论信息存储在外部数据库中,并使用自定义数据提供程序引用它。我已从共享源(此处)下载了 NorthwindDataProvider,并将其更改为使用包含以下内容的表:评级、文本和唯一标识符字段,用于存储评论附加到的 Sitecore 中的产品 ID。
模板字段是一个下拉链接,数据源设置为目录中的产品。
当我使用 sitecore 内容编辑器在自定义数据提供程序中编辑评论时,即使我选择填充的产品之一并使用 sitecore 保存,下拉链接也会显示“值不在选择列表中”。
它将 ID 保存在数据库中,但如果我查看原始值,它会显示不带大括号的 ID。工作 droplink 字段的原始值似乎包含括号。
为了创建评论,我使用 jquery post 到 web 服务,该服务使用外部数据上下文写入数据库。我应该使用一些 Sitecore API 来代替自定义数据提供程序吗?
使用自定义数据提供程序的任何信息都会有所帮助。我找到的文档都说明了可以做什么,但我正在努力寻找实际的实现。
How do bind a DropLink using a custom dataprovider?
More info:
I am trying to build a product catalogue site using Sitecore. Each product in the sitecore content tree can have a star rating and short text review attached to it (which will be linked to a user extended with a profile provider but that is another question).
I am planning to store the review information in an external database and reference it using a custom dataprovider. I have downloaded the NorthwindDataProvider from the Shared Source (here) and have altered it to use a table which contains the rating, text and a uniqueidentifier field to store the ID of the product from in sitecore the review is attached to.
The template field is a droplink and the datasource is set to the products in the catalogue.
When I edit a review in the custom dataprovider using the sitecore content editor, the droplink states 'Value not in selection list' even if I select one of the populated products and save using sitecore.
It is saving the ID in the database but if I look at the raw value it displays the id without the curly brackets. Working droplink fields' raw values appear to contain the brackets.
To create a review, I am using a jquery post to a webservice which writes to the database using an external datacontext. Should I be using some Sitecore API to use the custom dataprovider instead?
Any information using custom dataproviders would be helpful. The documentation I've been able to find has all stated what can be done but I'm struggling to find actual implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,第一件事是您有一个模板字段,并且您正在使用 droplink,它将存储所选项目的 guid。我不太清楚您是否将数据源指向 Sitecore 项目。但如果您使用 droplink,这一点至关重要。以下是我建议的最直接的方法:
创建一个模板,在其中添加字段来处理处理目录项的逻辑。如何做到这一点是您的选择,Sitecore 并不关心,因为它只处理项目,而它关心的只是查找项目...您编写业务逻辑来操作外部数据。
一旦您拥有存储目录项的文件夹,您就可以轻松编写由 Sitecore 中的规则引擎或定期运行的 Sitecore 任务触发的脚本,以使您的目录项添加/更新或删除相应的 Sitecore 项列表。
此外,另一个实现起来更复杂的选项,但如果您的站点上有多个数据源,则是一种有效的方法,即使用对象框架(如实体框架)作为数据对象层,允许您创建和使用任何数据源填充公共对象。
希望这有帮助!
So the first thing is that you have a template field and you're using droplink which is going to store the guid for the item selected. I'm not quite clear on whether or not you're pointing the datasource to a Sitecore item or not.. but that's essential if you're using droplink. Here's what I would suggest instead for the most straight forward way to do this:
Create a template that you add fields to handle the logic dealing with your catalog items. How you do that is your choice and Sitecore doesn't care since its only going to deal with the item and all it cares about is finding an item... you write business logic to manipulate the external data.
Once you have a folder that stores your catalog items, you could easily write a script to be triggered by the Rules engine in Sitecore or a Sitecore task that runs regularly to get your catalog items to add/update or remove the corresponding list of Sitecore items.
Also, another option that is more complex to implement, but if you have multiple data sources on your site, is a valid approach, is to use an object framework (like the Entity framework) as a data object layer that allows you to create and populate common objects with from any data source.
Hope this is helpful!