0
votes

I have create a module in Orchard cms, In which I have created the custom form say for 'staff list'. For the Custom form of staff list I have created the different field like Name, age, phone , gender etc..in a table 'staffDetails' through dataManuputaion class. For Add and edit the staff Detail I follow the same procedure and created admin UI through ContentPartDriver class. And I have also created the custom mvc view page for client section where I show all the staff details in grid. All the process is working fine. Now I want to add a image upload in admin add/edit section in of staff detail. And same uploaded image I want show in client section in grid respect to each staff detail.Can anyone tell me how to add image and get it url to show in client section. How the whole process will work. Let me know if any more detail required.

2

2 Answers

2
votes

Add MediaLibraryPickerField after create table in Migration class.

        SchemaBuilder.CreateTable("StaffRecord", table => table
            .ContentPartRecord()
            .Column<string>("Name", col => col.WithLength(100))
            .Column<string>("SmallPhoto", col => col.WithLength(500))
            .Column<bool>("IsActive", col => col.WithDefault(true))
        );

        ContentDefinitionManager.AlterPartDefinition("StaffPart", part => part
            .WithField("SmallPhoto", field => field
                .OfType("MediaLibraryPickerField")
                .WithDisplayName("Small Photo")));
0
votes

The media library fields that you can use in the admin won't work on the front-end. You'll have to build your own equivalent part or field.