Orchard helloworld, orchardhelloworld
Link: http://www.orchardproject.net/docs/Building-a-hello-world-module.ashx
Command Line Syntax: http://www.cnblogs.com/esshs/archive/2011/06/09/2076129.html
Enable the automatic generation of hardware hard code: orchard> feature enable Orchard. CodeGeneration
1. Generate the module structure
Run the following command to create the HelloWorld module:
Startup module command: codegen module HelloWorld
(Orchard actually creates a VS Project (HelloWorld. csproj) for us, so we can use the VS development module)
2. modify the configuration
Modify: module.txt
3. Add a route
Create a Route file Route. cs in the HelloWorld root directory
Using System. collections. generic; using System. web. mvc; using System. web. routing; using Orchard. mvc. routes; namespace HelloWorld {public class Routes: IRouteProvider {public void GetRoutes (ICollection <RouteDescriptor> routes) {foreach (var routeDescriptor in GetRoutes () routes. add (routeDescriptor);} public IEnumerable <RouteDescriptor> GetRoutes () {return new [] {new RouteDescriptor {Priority = 5, Route = new Route ("HelloWorld ", // this is the name of the page url new RouteValueDictionary {"area", "HelloWorld"}, // this is the name of your module {"controller ", "Home" },{ "action", "Index" }}, new RouteValueDictionary (), new RouteValueDictionary {"area ", "HelloWorld"} // this is the name of your module}, new MvcRouteHandler ())}};}}}View Code
4. Create a controller
Controllers folder (if not, create one). In this folder, create the HomeController. cs File
Using System. web. mvc; using Orchard. themes; namespace HelloWorld. controllers {[Themed] public class HomeController: Controller {public ActionResult Index () {return View ("HelloWorld ");}}}View Code
5. Create a view
Create a sub-folder named Home in the Views folder of the module root directory. In the Views/Home folder, create a View File named HelloWorld. cshtml and enter the following content:
6. Update the project file
Open the HelloWorld. csproj file and add:
<ItemGroup>
<Compile Include="Routes.cs"/>
<Compile Include="Controllers/HomeController.cs"/>
ItemGroup>
Add the following to make the View File included in the project:
<Content Include="Views/HelloWorld.cshtml" />
7. Activation Module
Activation module command: feature enable HelloWorld
8. Modules
Http: /localhost: 30321/OrchardLocal/HelloWorld