This project is read-only.

Trying to create a module and could do with Orchard API

Topics: Customizing Orchard, General, Writing modules
Apr 27, 2011 at 7:10 PM


We're attempting to create a module for use with our orchard website, but we're finding the going a little tough.

We've viewed the examples for creating a module , but the dummy hello world example is a little sparse to say the least

In our example we're trying to create a slider (front page, or any part of site) and in admin would like to give the backend user the ability to enter whatever text they wish, by integrating the tiny mce plugin


I have 2 questions for now

1)      TinyMCE. Is there any way to use TineMCE Orchard Module (like HTML.TineMCE() ) instead of


@Html.TextArea("Text", (string)Model.Text, 25, 80,

   new Dictionary<string,object> {

          {"class", "html tinymce"},


          {"data-mediapicker-title",T("Insert/Update Media")}



2)       I’ve declared following record


namespace ThemesOrchard.Slider.Models


   public class SliderRecord


       public virtual int Id { get; set; }



       public virtual string Title { get; set; }



       public virtual int SlidesAmount { get; set; }



       public virtual bool AutoplayEnabled { get; set; }



       public virtual int AutoplayInterval { get; set; }



       public virtual bool LoopEnabled { get; set; }



       public virtual bool AnimationSpeed { get; set; }



       public virtual int Width { get; set; }



       public virtual int Height { get; set; }




And used it in my AdminController


namespace ThemesOrchard.Slider.Controllers



   public class AdminController : Controller


       private readonly IRepository<SliderRecord> _sliderRepository;


       public AdminController(IRepository<SliderRecord> sliderRepository)


           _sliderRepository = sliderRepository;



       // GET: /Admin/


       public ActionResult Index()


           return View(_sliderRepository.Table);





In Index action I get the following error,

SQL error

Screen shot

We're coding in mvc 2, .net framework 4.0 and have tried to use both MS SQL and SQL server compact databases


Can anyone shed some light?


Thank you so much for your time!

Apr 27, 2011 at 7:36 PM

Did you write a migration?

Apr 27, 2011 at 8:07 PM

do you mean a script to  migrate something from an old site?

This is for a brand new site. I am not migrating anything

If i am incorrect , please enlighten me

Apr 27, 2011 at 8:34 PM

No, a data migration, in order to actually create the table in the database. See for example.

Apr 27, 2011 at 8:59 PM

ok,  we'll look at data migration, and i thank you for your help, we'll report back on it.


Any chance you know the answer to the first question (integrating tiny mce into the module) perhaps i should have posted it as a separate question

Apr 27, 2011 at 9:00 PM

Look at how the body part is doing it, there is nothing magical ;) There might be modules on the gallery doing it too.

Apr 28, 2011 at 7:53 PM

not exactly magic.. but a little bit of logic and some documentation might help.

Having to trawl through other modules that may or may not do what we're looking for just doesnt seem logical when you are trying to grow a CMS,

Can anyone provide me with code for a snippet with short description how to embeded tinyMCE


Thank you very much

Apr 28, 2011 at 8:21 PM

You can look at Orchard.Core/Common/Views/EditorTemplates/Parts.Common.Body.cshtml to see how the BodyPart is embedding the TinyMCE. It makes a call to @Display.Body_Editor(Model) which creates a "shape" which actually maps to the Body.Editor.cshtml templates in ~/Views.

The TinyMCE module overrides the Body.Editor.cshtml to supply its own editor view.

Actually it is all kind of magical but once you get used to it it's very easy to reference other templates and build shapes from models.

But, let's just think about approaching what you're trying to do in another way.

Basically you want a HTML editor in the back end. So have you tried just adding a HtmlField to a custom content type?

Apr 29, 2011 at 8:49 PM

this sounds very helpful info, we're going to work with it! thanks!