SDL Tridion 2011 中 MultiLineText 字段的 MaxLength 限制 [英] MaxLength restriction for MultiLineText field in SDL Tridion 2011

查看:25
本文介绍了SDL Tridion 2011 中 MultiLineText 字段的 MaxLength 限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的架构源如下所示:

<xsd:schema xmlns="uuid:b8fd4596-56ec-4718-ad00-bf2a70a148c2" xmlns:tcmi="http://www.tridion.com/ContentManager/5.0/Instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="uuid:b8fd4596-56ec-4718-ad00-bf2a70a148c2">
<xsd:import namespace="http://www.tridion.com/ContentManager/5.0/Instance"></xsd:import>
<xsd:annotation>
    <xsd:appinfo>
        <tcm:Labels xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
            <tcm:Label ElementName="description" Metadata="false">Description</tcm:Label>
            <tcm:Label ElementName="multiline" Metadata="false">Multiline</tcm:Label>
        </tcm:Labels>
    </xsd:appinfo>
</xsd:annotation>
<xsd:element name="Blog">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="description" minOccurs="0" maxOccurs="1">
                <xsd:annotation>
                    <xsd:appinfo>
                        <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml>
                    </xsd:appinfo>
                </xsd:annotation>
                <xsd:simpleType>
                    <xsd:restriction base="xsd:normalizedString">
                        <xsd:minLength value="1"></xsd:minLength>
                        <xsd:maxLength value="20"></xsd:maxLength>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="multiline" minOccurs="0" maxOccurs="1" type="tcmi:MultiLineText">
                <xsd:annotation>
                    <xsd:appinfo>
                        <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0">
                            <configuration xmlns="http://www.sdltridion.com/2011/SiteEdit">
                                <field>
                                    <editable>true</editable>
                                </field>
                            </configuration>
                        </tcm:ExtensionXml>
                        <tcm:Size xmlns:tcm="http://www.tridion.com/ContentManager/5.0">5</tcm:Size>
                    </xsd:appinfo>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element></xsd:schema>

我可以对xsd:normalizedString"类型字段使用 maxlengthminLength 限制,但我无法对xsd:normalizedString"类型字段使用相同的限制tcmi:MultiLineText"类型.有谁知道我如何在那种类型的领域使用它们?

I'm able to use the maxlength and minLength restrictions on a "xsd:normalizedString" type field, but I'm not able to use the same restrictions for the "tcmi:MultiLineText" type. Anyone knows how can I use them on that type of field?

如果无法在该领域使用该限制,我知道还有其他方法可以验证 Tridion 中保存的内容(正如 Nuno 和 Robert 在 http://nunolinhares.blogspot.com.es/2012/07/validating-content-on-save-part-1-of.htmlhttp://www.curlette.com/?p=913,感谢您的工作!)但我想找到避免使用事件的解决方案.还有其他想法吗?

In case it's not possible to use that restrictions in that field, I know there are other ways of validating content on save in Tridion (as Nuno and Robert explained in http://nunolinhares.blogspot.com.es/2012/07/validating-content-on-save-part-1-of.html and http://www.curlette.com/?p=913, thanks for that job!) but I would like to find a solution avoiding the use of events. Any other ideas?

推荐答案

不幸的是,这不能在多行字段上完成.这适用于启用 RTF 的字段和多行纯文本字段.

Unfortunately this can not be done on multi-line fields. This holds true for both RTF enabled fields and multi-line plain text fields.

这是设计使然(实际上很有意义),因为尝试限制文本通常与文本使用的空间量有关,并且这些字段支持换行符(以及其他格式RTF 启用字段),因此字符串长度与文本使用的空间几乎没有关系.

This is by design (and actually makes a lot of sense), as trying to limit text is normally to do with the amount of space used by the text, and these fields support line breaks (and other formatting in the case of RTF enabled fields) so the string length has little to do with the space used by the text.

如果您的字段是 RTF 字段,您可以编写一个截断"XSLT 来应用于文本.否则,您将需要使用上面提到的解决方案之一.

If your field is an RTF field, you could write a "Truncate" XSLT to apply to the text. Otherwise you will need to use one of the solutions you have referenced above.

或者,如果文本太长,您可以考虑使用输出模板截断文本.

Alternatively you might consider truncating the text with your output templates if it is too long.

这篇关于SDL Tridion 2011 中 MultiLineText 字段的 MaxLength 限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆