有没有办法添加一个基本上是现有数据类型分组的 Umbraco 自定义数据类型? [英] Is there a way to add a Umbraco Custom Data Type that basically was a grouping of existing data types?

查看:32
本文介绍了有没有办法添加一个基本上是现有数据类型分组的 Umbraco 自定义数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在许多不同的文档类型上,我必须添加相同的 3 种原生 Umbraco 数据类型

  1. 内容选择器
  2. 文本字符串
  3. 文本字符串

有人建议我看看是否有办法创建一种新的自定义数据类型,基本上可以将这 3 种数据类型包装成新的数据类型.

我查看了 nibble.be 的网站,发现有几种不同的方法可以创建自定义数据类型(使用 usercontrol 包装器,或 3 类方法).但是,我不确定用于对现有数据类型进行分组的自定义数据类型是否是正确的路线.

一方面,我们在 Umbraco 旁边使用 MVC,并大量使用 Razor 视图.由于文档类型属性别名用于从内容页面中从 Umbraco 获取值,因此我不知道这仍然是可能的,或者您将如何获取具有嵌入数据类型的自定义数据类型的属性值.

是否有一种工作方式或更好方式来完成此解决方案,因为必须在需要的任何文档类型上添加相同的字段?我虽然关于文档类型父级的分层方法只有这 3 种数据类型(内容选择器和 2 个文本字符串),但这意味着必须将页面需要的任何文档类型放在此父文档类型下,只是为了继承这一事实这组属性.

解决方案

如果您希望将多个属性嵌入到单个数据类型中:

有许多可用的嵌入式数据类型;数据类型网格嵌入式内容可重复的自定义内容 是我所知道的三个.三者都将他们的信息存储为 xml,这样可以通过 xslt 和 razor 轻松访问.

DataType Grid 是 uComponents 的一部分,因此得到了积极开发.它也是开源的,因此鼓励贡献.嵌入内容和可重复自定义内容虽然仍然有用,但目前似乎没有任何支持,因此没有改进计划.我认为它们已获得开放源代码许可,但据我所知,源代码尚未公开.

我认为您不能像在嵌入式内容(可能是功能请求)中那样对存储在 DataType Grid 中的行/项目数设置限制.

在您计划推出自己的解决方案之前,先看看其中的一些解决方案.但是,如果您仍然想要编写自己的数据类型,我建议您阅读 Tim Geyssens 关于使用 用户控件包装器,带有数据编辑器设置,以及将数据序列化为 xml.他的数据类型大师"视频也很有帮助,也涵盖了这些主题.>

如果您想将您的资源组织成组:

Tom Fulton 最近发布了一种新的包/数据类型 可能满足您需求的文档类型字段集.它允许您将字段组合在一个字段集中.这是屏幕截图:

On a number of different document types, I have to add the same 3 native Umbraco data types

  1. content picker
  2. TextString
  3. TextString

It was suggested to me to see if there is a way to create a new custom data type that would basically wrap those 3 datatypes into a new datatype.

I looked at nibble.be's site and see there is a couple different ways to go about creating custom data types (using the usercontrol wrapper, or 3 class approach). However, I am not sure that a custom data type for grouping existing datatypes would be the correct route.

For one thing, we are using MVC along side Umbraco with a heavy use of Razor views. Since the document type property alias is used to acquire values from Umbraco from the content page, I don't see how this would still be possible or how you would go about getting the property value of a custom datatype that has embedded datatypes.

Would there be a working way or a better way to accomplish this solution for having to add the same fields on any document type that they are needed? I though about hierarchical approach with a document type parent with only these 3 data types (content picker and 2 textstrings), but that would mean having to put any document type that a page would need under this parent document type simply for the fact to inherit these group of properties.

解决方案

If you're looking to embed multiple properties into a single datatype:

There are a number of embedded datatypes available; DataType Grid, Embedded Content, and Repeatable Custom Content are the three I know of. All three store their information as xml which allows easy access via both xslt and razor.

The DataType Grid is part of uComponents and is therefore actively developed. It is also open source and therefore contributions are encouraged. Embedded Content and Repeatable Custom Content, while still useful, don't appear to have any current support and therefore no plans for improvement. I think they are licensed as open source, but the source isn't publicly available as far as I can tell.

I don't think you can set a limit on the number of rows/items stored in the DataType Grid, like you can in Embedded Content (perhaps a feature request).

Take a look at some of these solutions before you plan on rolling your own. But if you still feel the urge to code out your own data type, I'd recommend Tim Geyssens' articles on created custom datatypes using the user control wrapper, with data editor settings, and serializing the data as xml. His "Master of Datatypes" video is also really helpful and covers those topics as well.

If you're looking to organize your properties into groups:

Tom Fulton published a new package/data type recently called Document Type Fieldsets that may fit your needs. It allows you to group fields together in a fieldset. Here's a screen shot:

这篇关于有没有办法添加一个基本上是现有数据类型分组的 Umbraco 自定义数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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