[RESOLVED] Routing - multiple URL for same content type

Topics: Customizing Orchard, Francais (French), General, Troubleshooting, Writing modules
Apr 11, 2013 at 8:12 PM
Hello,

I have a custom module that implements a customize Google Maps.

I use a class Driver to display my shape.

I use Autoroute part with the pattern {Content.Slug} but I need to uses multiples sub url to display the same Shape.

I have mapOrchard/display-map that display a general map. When I click on a zone, I use a history pushstate to modify window href as mapOrchard/display-map/zone/1 (1 represent id of the zone clicked).
I need it in url because I would like to use link a href=mapOrchard/display-map/zone/1 that display directly map center and selected to zone 1.

I don't find on documentation or on google a solution to my problem.

How can I display same shape content with different url:

mapOrchard/display-map
mapOrchard/display-map/zone/{ZonePartRecord.Id}
mapOrchard/display-map/zone/{ZonePartRecord.Id}/subZone/{ZonePartRecord.SubId}

I would like that all these urls display my Shape map.

Here is my display method:
protected override DriverResult Display(GMapFrontPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Parts_GMapFront",
                                () => shapeHelper.Parts_GMapFront(GMapFrontPart: BuildViewModel(part)));
        }
Thanks for your help
Coordinator
Apr 12, 2013 at 1:25 AM
Write your own IRouteProvider.
Apr 12, 2013 at 8:04 AM
Hello Bertrand,

Thanks for your help.

I have now my class Routes.cs that implements IRouteProvider.
But I don't have my own controller for my Content items. How can I call the default Orchard controller ? What is the value in controller of RouteValueDictionary ?

my error:
 Controller ... was not found or does not implement IController.
my route class:
            new RouteDescriptor {
                    Route = new Route(
                        "display-map/Zone/{ZoneId}",
                        new RouteValueDictionary {
                            {"area", "ShowMap"},
                            {"controller", "???"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "ShowMap"}
                        },
                        new MvcRouteHandler())
                },
                new RouteDescriptor {
                    Route = new Route(
                        "display-map/Zone/{ZoneId}/SubZone/{SubZoneId}",
                        new RouteValueDictionary {
                            {"area", "ShowMap"},
                            {"controller", "???"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "ShowMap"}
                        },
                        new MvcRouteHandler())
                }
            };
I need to use area of Orchard to call default controller ? I use Display method in Driver to render my content shape.
Developer
Apr 12, 2013 at 1:12 PM
Yes, if you want your routes to use the default ItemController of the Contents module, you'll need to use "Orchard.Contents" as the area and "Item" as the controller.
However, don't expect that the default controller will know what to do with your {ZoneId} token. If this is something you want to act upon, you may want to write your own controller, from which you render the content item (using an IContentManager) and do other things (related to {ZoneId}).
Apr 12, 2013 at 9:36 PM
Call to default ItemController doesn't works for me.

I create my own controller and use IContentManager to render my content.

Thanks for your help !