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:
- Run Orchard.exe located within the bin folder of the Orchard Project (Console application)
- Run the Orchard Instance in the browser and search in the Module Gallery for Code Generation module; install this module.
- Ensure the Code Generation module is enable by running the following command in the Orchard console environment:
feature enable Orchard.CodeGeneration
- 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:
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.