Bug(feature add): Autoroute Import/Export missing "PromoteToHomePage"

Topics: Core, Customizing Orchard, Troubleshooting
Mar 5, 2012 at 5:54 AM
Edited Mar 5, 2012 at 5:55 AM

The old RoutePart had a great feature that could be used in recipes or import/export where the RoutePart detected and appropriately set a bool as part of the RoutePart export xml if the content type was the home page.


With AutoRoute, the concept is there (somewhere).  

I believe I have it exporting correctly by adding this code to the Exporting Method in AutoroutePartDriver.cs


            // retrieve home page
            var homepage = _aliasService.Get(string.Empty);
            var displayRouteValues = _contentManager.GetItemMetadata(part).DisplayRouteValues;

            if (homepage.Match(displayRouteValues))
                context.Element(part.PartDefinition.Name).SetAttributeValue("PromoteToHomePage", "true");


Unfortunately I'm a bit over my head trying to get it to correctly import this elegantly but here is what I did on the import and it works.
This is based on code from the editor:  

var promoteToHomePage = context.Attribute(part.PartDefinition.Name, "PromoteToHomePage");
            if (promoteToHomePage != null)
                if (Convert.ToBoolean(promoteToHomePage))
                    part.DisplayAlias = "/";

Could someone help find the correct and elegant solution to this?

Mar 5, 2012 at 4:38 PM

Please file a bug if you think the homepage can't be exported. I would assume that an alias == "" would do it ... but to be tested.

Mar 6, 2012 at 2:17 AM


Work Item:


per the additional info in the workitem, I think my solution is overly complex.  the alias for the home page should simple be Alias="/" instead of what it does now which is null or blank. on the output.  So:


<AutoroutePart Alias="" UseCustomPattern="false"/>

should be:

<AutoroutePart Alias="/" UseCustomPattern="false"/>

The extra slash sets the part alias upon import.