How to install a new Orchard module on your home page via code

I am very new with orchard.

To study the development of the gardening module, I completed the documentation and tried to create a commerce module.

A module consists of a product part and a type of product that has a product part.

During the enable module, he will create an administrative and home menu for this module "Commerce" and "Shop", respectively.

My questions

  • How to make this module the main page during the enable module. In other words, do I need an Index method that the HomeController module processes the home URL?
  • How can I get the store menu in front of the home menu or register this module in the main menu?

I am adding the source code, please download it from the following link

download source code

+3
3

, Orchard - IHomePageProvider.

+4

migrations.cs :

        //create a page page
        var homepage = _contentManager.Create("Page");
        homepage.As<TitlePart>().Title = "My Home";            
        _contentManager.Publish(homepage);

        var homePageArp = homepage.As<AutoroutePart>();
        homePageArp.DisplayAlias = String.Empty;            
        _autorouteService.PublishAlias(homePageArp);

, Orchard - ; , . AutoroutePartHandler Orchard.Autoroute( Alias):

            // regenerate the alias for the previous home page
            var currentHomePages = _orchardServices.ContentManager.Query<AutoroutePart, AutoroutePartRecord>().Where(x => x.DisplayAlias == "").List();
            foreach (var current in currentHomePages) {
                if (current != null) {
                    current.CustomPattern = String.Empty; // force the regeneration
                    current.DisplayAlias = _autorouteService.Value.GenerateAlias(current);
                }
                _autorouteService.Value.PublishAlias(current);
            }


        _autorouteService.Value.PublishAlias(part);

autoroute, ; " " , "/", , , "/" String.Empty, , .

( Orchard 1.6)

+1

, , (, ). , , . , ( mvc functionallity). ExtendedRegistration (Routes.cs), , .

Here I redefine the standard account / registration URL. There should be nothing to prevent you from overriding the default HomeController.

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 = 19,
                    Route = new Route(
                        "Users/Account/Register",
                        new RouteValueDictionary {
                            {"area", "itWORKS.ExtendedRegistration"},
                            {"controller", "Account"},
                            {"action", "Register"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "itWORKS.ExtendedRegistration"}
                        },
                        new MvcRouteHandler())
                }
            };
        }
    }
0
source

All Articles