在Orchard CMS中使用url alternate覆盖内容类型的详细信息模板

时间:2013-01-13 20:43:58

标签: orchardcms orchardcms-1.6

是否有人知道是否可以使用网址备用模板覆盖ContentType的DisplayType模板?例如,是否可以覆盖模板: Content-Page.Detail.cshtml与Content-url-homepage-Page.Detail.cshtml?玩了一下后,似乎并非如此。有谁知道我想要实现的目标是否可行?

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以通过启用“形状跟踪”来查看形状的所有可用替代项。功能和查看替代列表,例如http://devhammer.net/blog/Customize-Orchard-CMS-with-Designer-Tools

例如,在主页的主要内容项目中,我开箱即用:

~/Themes/MyTheme/Views/Content.cshtml
~/Themes/MyTheme/Views/Content-url-homepage.cshtml
~/Themes/MyTheme/Views/Content.Detail.cshtml
~/Themes/MyTheme/Views/Content-Page.cshtml
~/Themes/MyTheme/Views/Content-10.cshtml
~/Themes/MyTheme/Views/Content-Page.Detail.cshtml
~/Themes/MyTheme/Views/Content-10.Detail.cshtml

您的选择是添加或扩展现有的备用工厂,例如Orchard.DesignerTools.Services.UrlAlternatesFactory,例如。

// appends [ShapeType]__url__[Url]_[DisplayType] alternates
context.ShapeMetadata.Alternates = _urlAlternates.Value.Select(url => 
    context.ShapeMetadata.Type + "__url__" + url + "_" + 
        context.ShapeMetadata.DisplayType)
        .Union(context.ShapeMetadata.Alternates)
        .ToList();

这将为您提供备用     〜/主题/ MyTheme的/查看/内容URL-homepage.Detail.cshtml

或使用现有的替代品之一,如

~/Themes/MyTheme/Views/Content-10.Detail.cshtml

看起来它可能适合您的目的(对我来说使用id并不像使用url一样干净)

我还尝试调整“网址备选”的功能优先级。功能,以便url替换附加到所有其他现有的替代项,因为它从代码中出现,但据我所知,这是不起作用或不支持。