Creating an Orchard Module

In my last post, Prep-Work to Developing an Orchard Module, I outlined the steps I took to fork the Orchard Source Code and clone it to my local development machine using TortoiseHg and VisualHg.  Now that I have the Orchard Project on my machine, I’m ready to create an Orchard Module.  There is already good documentation on creating an Orchard Module from the community (Walkthrough Writing An Orchard Module – Orchard Documentation,Creating a module with a simple text editor – Orchard Documentation, etc.), but I’ll regurgitate some of it here hopefully to solidify the process in my mind and perhaps yours too!

Here’s how I created the module structure:

Creating a Module Project from the Command line:

I followed the steps outlined in the Orchard Documentation, Creating a module with a simple text editor, using the code generation module and the Orchard console to build the module project shell.

  1. Run Orchard.exe located within the bin folder of the Orchard Project (Console application)
  2. Run the Orchard Instance in the browser and search in the Module Gallery for Code Generation module; install this module.
  3. Ensure the Code Generation module is enable by running the following command in the Orchard console environment:

    feature enable Orchard.CodeGeneration

  4. Finally, create the module structure by using the Code Generation command within the console environment:

    codegen module Slider

    Where Slider is the name of your module.

When finished, you should see the new module structure in the Orchard Project under the Modules Solution folder (in addition, you’ll see the module physically located in the Orchard.Web\Modules folder of the project):


If you now run the Orchard project, you’ll see a new feature in the modules section labeled Slider (or whatever name you chose).


This is coming from the Module.txt file that was created by the Code Generation:


If the Module.txt file did not exist, Orchard would not be able to pick up your Module and list it in the administrative section.

Also pertinent to point out, the Project includes references to Orchard.Core and Orchard.Framework among other typical MVC references:


And the Scripts and Styles folders all contain their own Web.config file in addition to a Web.config file in the root of the project.  These configuration files tell Orchard that any files requested from these folder should be handled by a StaticFileHandler.  The details of why this is needed eludes me right now, but suffice to say these are important attributes to displaying the content (JavaScript files, CSS files, etc.) in these folders.

So there you have it!  A module shell that provides you with the starting point for bending Orchard to your will.  Now time to harness the power of the module by doing something useful.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s