果园CMS路由问题 [英] orchard cms routing question

查看:100
本文介绍了果园CMS路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创造了一些自定义的内容类型,包括路线的一部分,所以我的内容管理者可以编辑项目的蛞蝓。我有没有运气配置,使我自己的控制器,以服务为这些项目要求的路由。

I have created some custom content types which include the route part so my content managers can edit the slugs for the items. I am having no luck configuring a route that will enable a controller of my own to serve requests for these items.

为核心的可路由模块路径的ItemController路由具有我所试图使,它利用一个IRouteConstraint,类似于博客模块如何实现我想要做的,具有较低优先级的路线10.一个优先事项,但仍然没有运气。

The route for paths to the ItemController in the core Routable module has a priority of 10. I have tried making a route that utilises an IRouteConstraint, similar to how the Blog module achieves what I want to do, with a lower priority but still no luck.

如果我让我的网址与结束/然后我的自定义路线被激活,因为那不符合我的内容项的路径。这不是一个理想的解决方案。我不明白为什么它不会提前发现一个属于可路由模块的我的自定义路线。

If I make my URLs end with a / then my custom route is activated, as then it does not match the path of my content items. This is not a desirable solution. I cannot understand why it won't discover my custom route ahead of the one belonging to the Routable module.

任何帮助将大大AP preciated,提前很多感谢。

Any help would be greatly appreciated, many thanks in advance.

更新:结果
这里是我的GetRoutes方法从我IRouteProvider实现:

UPDATE:
Here is my GetRoutes method from my IRouteProvider implementation:

    public IEnumerable<RouteDescriptor> GetRoutes()
    {
        return new[] {
            new RouteDescriptor
            {
                Priority = 0,
                Route = new Route(
                    "Admin/Jugganort/{controller}/{action}/{id}",
                    new RouteValueDictionary {
                                                {"area", "Jugganort"},
                                                {"controller", "Area"},
                                                {"action", "List"}
                                            },
                    new RouteValueDictionary(),
                    new RouteValueDictionary {
                                                {"area", "Jugganort"}
                                            },
                    new MvcRouteHandler())
            },
            new RouteDescriptor
            {
                Priority = 9,
                Route = new Route(
                    "{location}/{merchant}/{promotion}",
                    new RouteValueDictionary {
                                                {"area", "Jugganort"},
                                                {"controller", "Home"},
                                                {"action", "Index"},
                                                {"merchant", UrlParameter.Optional},
                                                {"promotion", UrlParameter.Optional}
                                            },
                    new RouteValueDictionary { 
                        { "location", _routeConstraint }
                    },
                    new RouteValueDictionary {
                                                {"area", "Jugganort"}
                                            },
                    new MvcRouteHandler())
            }
        }; 
    }  

_routeConstraint是一个简单的实现IRouteConstraint的,只是寻找的新城疫在路线的位置的硬$ C $光盘值。

_routeConstraint is a simple implementation of IRouteConstraint that just looks for a hardcoded value of "newcastle" for the location in the route.

是我RoutePart的理解不正确?将这些项目始终必须从可路由模块的ItemController担任了?是我唯一的选择用户交替渲染自定义形状?

Is my understanding of the RoutePart not correct? Will those items always have to be served up from the Routable module's ItemController? Is my only option to user alternates to render custom shapes?

果园论坛将是我的下一个停靠点。再次感谢您的帮助,您可能能够提供。

The orchard forums will be my next point of call. Thanks again for any help you may be able to provide.

推荐答案

您可以从您自己的控制器服务的项目也一样,肯定。唯一需要的就是将达到控制器的路线。然后,你可以回到你想要pretty任何东西:)

You can serve those items from your own controller too, sure. The only thing needed is a route that would reach your controller. Then, you can return pretty much anything you want:)

它看起来像你的URL都被一些其他途径(S)相匹配。如果您要覆盖默认路由,并确保你的人会首先比较,应指定更高的优先级(如11)。在Orchard.Core.Routable.Routes的包罗万象的航线有10当务之急,所以将赶上乃至匹配的URL你的路由。

It looks like your URLs are being matched by some other route(s). If you want to override the default route and make sure your one would be compared first, you should specify a higher priority (eg. 11). The catch-all route in Orchard.Core.Routable.Routes has a priority of 10, so will catch even the URLs matching your routes.

您没有提供用于在第一路径ID的默认值 - 这还可能会带来问题。如果没有明确在URL中指定的ID,它不会被匹配。

You haven't provided a default value for id in the first route - that can also pose a problem. If you don't explicitly specify id in an URL, it won't be matched.

顺便说一句,就是在第一路由的默认控制器,或者只是一个错字一个合适的名字?

Btw, is Area a proper name for the default controller in the first route, or just a typo?

这篇关于果园CMS路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆