简体   繁体   English

防止 tridion 组件字段中的特殊字符和架构更改

[英]Preventing special characters in tridion component field and changes in schema

In component, I should not allow any special characters to be entered.在组件中,我不应该允许输入任何特殊字符。 When I try to enter a comma, it should suggest "no special characters allowed".当我尝试输入逗号时,它应该提示“不允许使用特殊字符”。 Please suggest where do I make the necessary changes.请建议我在哪里进行必要的更改。 I tried making some changes in schema(source) like adding but not working.我尝试在架构(源)中进行一些更改,例如添加但不起作用。

<xsd:element name="FileName">
 <xsd:simpleType>
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="[a-zA-Z0-9_.' !@#$%^*()_+={}|/:;,>?/`~ ]"/>
  </xsd:restriction>
 </xsd:simpleType>
</xsd:element>

What you're asking for is a custom validation that may not be best accommodated via the Schema (XSD).您要求的是自定义验证,它可能无法通过架构 (XSD) 得到最佳适应。 You may be able to do it there via a feature called facets.您可以通过一个名为 facets 的功能在那里完成它。 Check the sdllive docs for examples.检查 sdllive 文档以获取示例。 You can make it give you validation error messages, but you cannot customize the messages themselves, and they are ugly and scary looking for the average content editor.你可以让它给你验证错误消息,但你不能自定义消息本身,而且对于普通的内容编辑器来说,它们是丑陋和可怕的。

The other approaches are:其他方法是:

1) develop a custom event via the Event System. 1) 通过事件系统开发自定义事件。 This is the easiest option IMO.这是 IMO 最简单的选择。 Simply throw an exception with a custom message on a Compenent Save event in the Init phase.只需在 Init 阶段的 Compenent Save 事件上抛出一个带有自定义消息的异常。

2) develop a custom GUI extension to do the validation. 2) 开发自定义 GUI 扩展来进行验证。 This IMO is more work than the above, but is achievable.该 IMO 比上述工作更多,但可以实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM