Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:23:48+00:00 2026-06-02T06:23:48+00:00

I created a content part and then added it to a content type in

  • 0

I created a content part and then added it to a content type in Orchard. But when I try to create a content item of that type, the fields for the part’s properties are not displayed. I’m looking for suggestions of where the problem might be.

UPD: the relevant code:

using JetBrains.Annotations;
using ArealAds.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using ArealAds.Models;
using ArealAds.Services;
using ArealAds.ViewModels;

namespace ArealAds.Drivers {
    [UsedImplicitly]
    public class AdDriver : ContentPartDriver<AdPart> {
        private readonly IAdService _adService;

        public AdDriver (IAdService adService)
        {
            _adService = adService;
        }

        protected override string Prefix {
            get { return "AdPart"; }
        }

        protected override DriverResult Display(
            AdPart part, string displayType, dynamic shapeHelper) {

            return ContentShape("Parts_Ad", () => shapeHelper.Parts_Ad(
                Title: part.Title,
                Url: part.Url,
                Email: part.Email,
                Phone1: part.Phone1,
                Phone2: part.Phone2,
                AreaName: part.AreaRecord.Name,
                AreaId: part.AreaRecord.Id,
                DistrictName: part.DistrictRecord.Name,
                DistrictId: part.DistrictRecord.Id,
                AllDistricts: part.AllDistricts));
        }

        //GET
        protected override DriverResult Editor(
            AdPart part, dynamic shapeHelper) {

            return ContentShape("Parts_Ad_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/Ad",
                    Model: BuildEditorViewModel(part),
                    Prefix: Prefix));
        }
        //POST
        protected override DriverResult Editor(
            AdPart part,
            IUpdateModel updater,
            dynamic shapeHelper) {

            var model = new EditAdViewModel();
            updater.TryUpdateModel(model, Prefix, null, null);

            if (part.ContentItem.Id != 0) {
                _adService.Update(
                    part.ContentItem, model);
            }

            return Editor(part, shapeHelper);
        }

        private EditAdViewModel BuildEditorViewModel(AdPart part) {
            var avm = new EditAdViewModel {
                Title = part.Title,
                Url = part.Url,
                Email = part.Email,
                Phone1 = part.Phone1,
                Phone2 = part.Phone2,
                AllDistricts = part.AllDistricts,
                Areas = _adService.GetAreas(),
                Districts = _adService.GetDistricts()
            };
            if (part.AreaRecord != null) {
                avm.AreaName = part.AreaRecord.Name;
                avm.AreaId = part.AreaRecord.Id;
            }
            if (part.DistrictRecord != null) {
                avm.DistrictName = part.DistrictRecord.Name;
                avm.DistrictId = part.DistrictRecord.Id;
            }
            return avm;
        }
    }
}

using System.ComponentModel.DataAnnotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;

namespace ArealAds.Models {
    public class AdRecord : ContentPartRecord {
        public virtual string Title { get; set; }
        public virtual string Url { get; set; }
        public virtual string Email { get; set; }
        public virtual string Phone1 { get; set; }
        public virtual string Phone2 { get; set; }
        public virtual AreaRecord AreaRecord { get; set; }
        public virtual DistrictRecord DistrictRecord { get; set; }
        public virtual bool AllDistricts { get; set; }
    }

    public class AdPart : ContentPart<AdRecord> {
        [Required]
        public string Title {
            get { return Record.Title; }
            set { Record.Title = value; }
        }

        public string Url {
            get { return Record.Url; }
            set { Record.Url = value; }
        }

        public string Email {
            get { return Record.Email; }
            set { Record.Email = value; }
        }

        public string Phone1 {
            get { return Record.Phone1; }
            set { Record.Phone1 = value; }
        }

        public string Phone2 {
            get { return Record.Phone2; }
            set { Record.Phone2 = value; }
        }

        public AreaRecord AreaRecord {
            get { return Record.AreaRecord; }
            set { Record.AreaRecord = value; }
        }

        public DistrictRecord DistrictRecord {
            get { return Record.DistrictRecord; }
            set { Record.DistrictRecord = value; }
        }

        [Required]
        public bool AllDistricts {
            get { return Record.AllDistricts; }
            set { Record.AllDistricts = value; }
        }
    }
}


@model ArealAds.ViewModels.EditAdViewModel

<fieldset>
  <legend>Area Fields</legend>

  <div class="editor-label">
    @Html.LabelFor(model => model.Title)
  </div>
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Title)
    @Html.ValidationMessageFor(model => model.Title)
  </div>

  <div class="editor-label">
    @Html.LabelFor(model => model.Url)
  </div>
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Url)
    @Html.ValidationMessageFor(model => model.Url)
  </div>

  <div class="editor-label">
    @Html.LabelFor(model => model.Email)
  </div>
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Email)
    @Html.ValidationMessageFor(model => model.Email)
  </div>

  <div class="editor-label">
    @Html.LabelFor(model => model.Phone1)
  </div>
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Phone1)
    @Html.ValidationMessageFor(model => model.Phone1)
  </div>

  <div class="editor-label">
    @Html.LabelFor(model => model.Phone2)
  </div>
  <div class="editor-field">
    @Html.TextBoxFor(model => model.Phone2)
    @Html.ValidationMessageFor(model => model.Phone2)
  </div>

  <div class="editor-label">
    @Html.LabelFor(model => model.AllDistricts)
  </div>
  <div class="editor-field">
    @Html.CheckBoxFor(model => model.AllDistricts)
    @Html.ValidationMessageFor(model => model.AllDistricts)
  </div>

  <table>
  <tr>
  <td>
  <div class="editor-label">
    @Html.LabelFor(model => model.AreaId)
  </div>
  <div class="editor-field">
    @Html.DropDownListFor(model => model.AreaId,
                          Model.Areas.Select(s => new SelectListItem {
                              Selected = s.Id == Model.AreaId,
                              Text = s.Name,
                              Value = s.Id.ToString()
                          }),
                      "Выберите район...")
    @Html.ValidationMessageFor(model => model.AreaId)
  </div>
  </td>
  <td>или</td>
  <td>
  <div class="editor-label">
    @Html.LabelFor(model => model.DistrictId)
  </div>
  <div class="editor-field">
    @Html.DropDownListFor(model => model.DistrictId,
                          Model.Districts.Select(s => new SelectListItem {
                              Selected = s.Id == Model.DistrictId,
                              Text = s.Name,
                              Value = s.Id.ToString()
                          }),
                      "Выберите округ...")
    @Html.ValidationMessageFor(model => model.DistrictId)
  </div>
  </td>
  </tr>
  </table>

</fieldset>


            SchemaBuilder.CreateTable("AdRecord", table => table
                .ContentPartRecord()
                .Column<string>("Title")
                .Column<string>("Url")
                .Column<string>("Email")
                .Column<string>("Phone1")
                .Column<string>("Phone2")
                .Column<int>("AreaRecord_Id")
                .Column<int>("DistrictRecord_Id")
                .Column<bool>("AllDistricts")
            );

            ContentDefinitionManager.AlterPartDefinition(
                typeof(AdPart).Name, cfg => cfg.Attachable());

            ContentDefinitionManager.AlterTypeDefinition(
                "ArealAds_Ad", cfg => cfg
                .WithPart("CommonPart")
                .WithPart("AdPart")
                .Creatable()
            );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:23:49+00:00Added an answer on June 2, 2026 at 6:23 am

    You’re probably missing an entry in placement.info.

    Add this into the placement.info file in your module (not the placement.info for yoru theme, since the theme is not active while you’re in the dashboard):

    `<Place Parts_Ad_Edit="Content:1" />`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a content type which has some fields and i want this fields
i created an additional content type called clients where I can create new client
I created a new content type for a wiki page library. I added this
I recently set up a local copy of Wordpress, added some content and created
I created an application that parses content of secured areas of one webpage after
I have created PS script that queries the Event Logs on my Servers then
The idea is simple: create a web part page in SP Designer 2010 that
How can I achieve the following: I have created a content type called journal,
I'm using the following query: INSERT INTO role (name, created) VALUES ('Content Coordinator', GETDATE()),
Can I avoid forwarding after content is created / saved ? I don't want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.