This project is read-only.

How to show MCE toolbar onto the Body Part Edit shape/template.

Topics: Customizing Orchard, General
Nov 9, 2012 at 3:23 AM
What is the exact configuration to make the MCE toolbar shown up with the Body Part edit shape/template?
  • Works: For content item created at the admin end, the MCE toolbar always shows with the BodyPart edit screen.
  • Not Works: However, if I wrote a controller to disply the BodyPart edit screen at the front end, i.e. with [Themed] attribute, the MCE toolbar is not showed up. And along the development, the toolbar might mysteriously show up.

Now I reinstall my package into another clean Orchard environment, the MCE toolbar is lost again with the BodyPart at the front end.

I would like to know how to controll it from appearing and disappearing?

Nov 9, 2012 at 3:27 AM

Why and how would you display the body part from a custom controller?

Nov 9, 2012 at 3:41 AM
Edited Nov 9, 2012 at 3:57 AM

Here is the data migration.

public int Create()
        cfg => cfg
    return 1;

Here is the controller.

public ActionResult Create()
     // Create as ContentItem:
    var myObj = _contentManager.New("MyObject");

    dynamic model = _contentManager.BuildEditor(myObj, this);

    // Return to List View
    return Redirect(Url.ListForAdmin());

I will just route to the action with URL: ~/MyObject/Create

Nov 9, 2012 at 3:54 AM

I don't understand, sorry.

Nov 9, 2012 at 3:55 AM

Strangely, if I add [Admin] attribute to the controller, the MCE toolbar would get displayed.

[ValidateInput(false), Admin] //If I changed Admin to Themed, the MCE Tool bar will not show up.
public class MyObjectController: Controller, IUpdateModel

    //... should add constructor and inherited methods ...//

    public ActionResult Create()
        // Create as ContentItem:
        var myObj = _contentManager.New("MyObject");

        dynamic model = _contentManager.BuidEditor(myObj);

        // Return to List View
        return Redirect(Url.ListForAdmin());

Nov 9, 2012 at 4:05 AM
Edited Nov 9, 2012 at 5:31 AM

Hi Bertrandleroy, sorry for not explaining well.

You know during the edit of Body part, there is a tool bar at the top, like:

U  A  <-  -> 

Is that called an MCE Tool bar? Is it from the TinyMce Module? It is not showing upon my screen if I used [Themed] attribute for the controller. But it does show up before, I just want to know what the codes and configurations are that might prevent its from displaying.

I know my questions may sound not smart. Thanks for your time to reply my post.

Nov 9, 2012 at 5:33 AM

Well, that's not the part I didn't understand. I'm starting to understand what you're trying to do, but I still don't get why you are redirecting at the end of the action.

If you are trying to display a form on the front-end, you should probably take a look at the custom forms feature, because it might already do what you are trying to do, and because if it doesn't, it will give you precious hints about how to get it right.

Nov 9, 2012 at 6:12 AM

Thank you bertrandleroy, I do mean to display a form on the front-end. And I will start to look at the custom forms module, thanks for your advise.

Nov 9, 2012 at 7:42 AM

Hi Bertrandleroy. I have found that, when I enable the Shape Tracing feature, my controller does get MCE tool bar rendered for [Themed] view on the front-end. However the Media Picker on the MCE tool bar would not function at all. Just to let you know, I will take your suggestion and go with custom forms anyway.