验证 Sitecore 项目名称的唯一性
对于 sitecore 项目,我需要验证项目名称的唯一性(以避免 url 重叠)
可以将“重复名称”项目验证规则添加到项目的模板中(要查看这些选项,请确保“显示标准字段”在内容编辑器功能区的“视图”选项卡中选择)
但是,可用的选项这里是将验证规则添加到
- 快速操作栏
- 验证按钮
- 工作流验证规则
我是否应该将其应用为工作流验证规则,并启用工作流(对于我的所有内容项)?这可行,但如果最终用户必须使用工作流程来做某事,那么他们似乎需要付出很大的努力。
我想要实现的是当用户尝试保存项目(并使用已使用的名称)时简单地显示验证消息。基本上,字段验证器在 sitecore 中的工作方式相同,
但这些选择似乎都没有达到这种效果。
所以我的问题是,实现这一目标的最简单方法是什么?
For a sitecore project, I need to validate the uniqueness of item names (to avoid url overlap)
It is possible to add the 'Duplicate name' Item validation rule to the item's template (to see these options, make sure 'show standard fields' is selected in the 'view' tab, in the content editor ribbon)
However, the options available here are to add the validation rule to the
- Quick Action bar
- Validation Button
- Workflow Validation Rules
Should I apply it as a workflow validation rule, and enable workflow (for all my content items)? That would work, but it seems like a lot of effort for the end user if they have to use workflow for something.
What I want to achieve is to simply show a validation message when the user tries to save the item (and uses a name which is already taken). Basically in the same way field validators work in sitecore
None of these choices seem to achieve this effect.
So my question is, what is the easiest way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
验证栏验证规则 - 在内容编辑器右侧的栏中运行。
您可能想要覆盖
item: saving
事件或contenteditor:save
命令。看一下item:saved
。OnItemSaved
事件触发项目的规则。如果您更改内容编辑器中的对话框或更新事件,您需要确保您的逻辑适用于内容树的特定部分 - 即 sitecore/content/home 和/或可能的安全角色。
我同意工作流程方面的工作量,但在某些情况下,对于此和其他验证要求可能非常有意义。
Validation Bar Validation Rules - Runs in the bar to the right of the content editor.
You may want to override the
item:saving
event or thecontenteditor:save
command. Take a look atitem:saved
. TheOnItemSaved
event triggers the Rules for an item.If you change the dialog in the content editor or update the events, you'll want to make sure that your logic applies to specific parts of the content tree - i.e. sitecore/content/home, and/or possible security role.
I agree about the amount of effort regarding workflow, but in certain cases, may make perfect sense for this and other validation requirements.
您可以在SDN上找到代码示例:
http://sdn.sitecore.net/Snippets/Item%20Handling/Validating/Validate%20a%20pspecial%20field%20on%20the%20Item%20save%20event.aspx
You can find a code example on SDN:
http://sdn.sitecore.net/Snippets/Item%20Handling/Validating/Validate%20a%20particular%20field%20on%20the%20Item%20save%20event.aspx
我为此撰写了一篇博客文章,其中使用了项目创建/保存事件。这是使用 Sitecore 7.2 实施和测试的。这是使用的配置:
I have a blog post out for this which uses the item create / save event. This was implemented and tested with Sitecore 7.2. Here's the config used: