果园cms:如何将媒体选择器字段添加到新模块 [英] orchard cms: how to add media picker field to anew module

查看:61
本文介绍了果园cms:如何将媒体选择器字段添加到新模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为果园cms构建一个模块.我想在模块中使用mediapiker模块.

I am building a module for orchard cms. I would like to use the mediapiker module in my module.

通过果园后端接口,可以向内容项添加模块.尚不清楚的是如何在另一个模块中使用一个模块.

Through the orchard backend interface, its possible to add a moudle to a content item. What is not clear, is how to use one module in another.

如何在Visual Studio的剃刀视图中添加mediapiker字段?

how do I add the mediapiker field to my razor view in visual studio?

推荐答案

您应该查看MediaPickerFieldDriver.cs和MediaPicker.Edit.cshtml.它们都在Orchard.Fields中.那应该给您您需要的一切.再说一次,您还不确定要做什么.如果您只是想将代码中的媒体选择器字段添加到您的内容类型中,则应该从迁移中完成,就像这样:

You should take a look at MediaPickerFieldDriver.cs and MediaPicker.Edit.cshtml. They are both in Orchard.Fields. That should give you everything you need. Then again it's not entirely clear what you are trying to do. If you are just trying to add a media picker field to your content type from code, then you should do it from the migration, like this:

ContentDefinitionManager.AlterPartDefinition("Product",
    builder => builder.WithField("ProductImage",
        fieldBuilder => fieldBuilder
            .OfType("MediaPickerField")
            .WithDisplayName("Product Image")));

更新:正如@ ed13在他的答案中指出的那样,对于较新版本的Orchard 1.x(1.10+),字段类型为 MediaLibraryPickerField 而不是 MediaPickerField

Update: As @ed13 points out in his answer, for more recent versions of Orchard 1.x (1.10+), the field type is MediaLibraryPickerField instead of MediaPickerField.

这篇关于果园cms:如何将媒体选择器字段添加到新模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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