适用于Archetypes的国家小部件
项目描述
适用于Archetypes的国家小部件
向Plone根目录添加了一个名为portal_countryutil
的新工具,允许您通过ZMI管理一个可能包含来自官方ISO国家列表的多个国家的区域列表。在安装时创建区域和其国家的完整列表。
提供三个小部件,您可以在自己的Archetype中使用
- CountryWidget
在Country工具中定义的区域和国家将被渲染为下拉列表(带有
<optgroup>
)。- AreaWidget
提供一个包含您已定义的所有区域的下拉列表。
- MultiCountryWidget
与LinesField一起使用,允许您选择多个国家
示例
以下代码演示了如何使用这些小部件
---- YourArcheType.py ---- # Import the widget/s: from Products.ATCountryWidget.Widget import CountryWidget, AreaWidget # Define the field/s in your schema: [...] StringField( 'country', validators=('isValidISOCountry',), widget=CountryWidget(label='Country', provideNullValue=1, # this is default nullValueTitle='-', # this is default omitCountries=None, # this is default, can be a # list of country codes which # are not displayed description='Select a country') ), [... and/or ...] StringField( 'area', widget=AreaWidget(label='Area', provideNullValue=1, # this is default nullValueTitle='-', # this is default description='Select an area') ), [... and/or ...] LinesField( 'countries', widget=MultiCountryWidget(label='Countries', omitCountries=None, # this is default, can be a # list of country codes which # are not displayed description='Select countries') ), [...]
在不使用Archetypes的情况下使用
要在外部使用自定义页面模板(例如在搜索表单中)中的国家列表,您可以直接使用国家工具提供的API
<select tal:define="countrytool here/portal_countryutils"> <option>Choose...</option> <optgroup label="Western Europe" tal:repeat="area countrytool/listAreas" tal:attributes="label area/name"> <option value="DE" tal:repeat="country area/countries" tal:content="country/name" tal:attributes="value country/isocc">Germany </option> </optgroup> </select>
有关如何自定义内容类型、向内容类型添加自定义字段的更多详细信息,请参阅Martin的教程:[http://plone.org/documentation/kb/richdocument/extending-atct](http://plone.org/documentation/kb/richdocument/extending-atct)
变更日志
- 2011-04-11
发布Plone 4兼容版本
- 2009-02-21
作为egg发布。
- 2006-04-19
添加了Norman H. Voss的补丁(缺少国家/重新排列默认区域)
更新了README文件,以涵盖MultiCountryWidget
- 2006-03-14
添加了多选小部件(MultiCountryWidget)
- 2005-09-02
与Plone 2.1(RC3)兼容
- 2005-06-29
为CountryWidget添加了参数‘omitCountries’。在此列表中的国家ISO代码将在选择中省略显示。
- 2005-02-20
添加了语言及其两位字母ISO代码的列表
- 2004-08-30
发布0.2版
添加了区域小部件
为小部件提供provideNullValue & nullValue属性
在安装程序中创建完整的区域-国家结构
迁移到AT 1.3 beta
- 2004-07-05
发布0.1.1版
添加了验证器
- 2004-06-29
初始发布0.1版
额外致谢
Norman H. Voss(2006年4月提供的补丁)
Alex Clark(2011年4月发布Plone 4兼容版本,从gocept主分支移动到collective)
项目详情
Products.ATCountryWidget-0.2.6.zip的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 329600d2778bd3000548710ae5298790850a55aedf1b024021fb5d1287b8b1ac |
|
MD5 | a264e414463e0a892caecd4da50412cc |
|
BLAKE2b-256 | f3b33860289dfd1a5c0d6f864a1f2d90b9651cff9e4c3423d4b4b52dd99afa54 |