This project is read-only.

Hide portions of a content item

Topics: Customizing Orchard, Writing modules
Oct 12, 2011 at 2:27 PM
Edited Oct 12, 2011 at 2:59 PM

Here's the scenario:

ContentType: Doctor
ContentPart: DoctorProfilePart (has a foreign key to user table)
Need to allow CMS admins to edit the Doctor content items, as well the user that's tied to the DoctorProfile be able to edit their DoctorProfilePart on the front-end. This also has to be indexable/searchable.

We originally were using the Contrib.Profile module with the aforementioned DoctorProfilePart attached to the profile, which worked great for everything, except one major caveat...only the SiteOwners permission is allowed to edit users in the CMS.  We need the ability to have non site-owners, maybe someone with doctor admin privileges, edit users and their profiles.

So our next attempt was what I described above, e.g., instead of attaching the profile part to a user, attaching it to a new Doctor Content type.  I was able to copy the following code from the profile module to build the doctor edit shape on the front side:

My controller action

public ActionResult Edit() {
            // Test ID#: 3097
            var physician = _cms.Query().ForPart<DoctorPart>()
                .Where(x => x.Id == 3097)

            var doctor = _doctorRepository.Get(x => x.Id == 3097);

            if (Services.WorkContext.CurrentUser == null)
                return HttpNotFound();

            //IUser user = Services.WorkContext.CurrentUser;
            //dynamic shape = Services.ContentManager.BuildEditor(user.ContentItem);

            dynamic shape = Services.ContentManager.BuildEditor(physician.ContentItem);

            return View((object)shape);

The view


<h1>@Html.TitleForPage(T("Edit Profile").Text)</h1>
@using (Html.BeginFormAntiForgeryPost()) {



The problem is, it's pulling in the routeable part (that has the set as homepage button, title, and url), and it's providing a publish button.  Maybe I'm going about this the wrong way. I'm hoping one of the following is true:

  • We can work around the site owner permissions needed to edit users
  • We can hide parts of a content item or customize it (the profile module just has a save button, I don't see how the author did that)
  • There's a different/better way to handle what I'm trying to accomplish.
Oct 12, 2011 at 2:35 PM
Edited Oct 12, 2011 at 2:41 PM

Well, it looks like the user shape only provides a save button, so that's how that's working.  I could probably live with the button saying "publish" though it'd be nice to customize it.  I'd like to be able to hide the save button that appears as well.

 What I really need is a way to hide the routeable part when showing the editor on the front-side of the site in this manner.  That I think would get me most of the way there.

Oct 12, 2011 at 4:22 PM

I was able to do most of this with URL placement, so I think that I've at minimum got that as a workaround...