MVC 站点地图提供商 & CSS样式
有谁知道如何自定义 MVC 站点地图提供程序的呈现,以便我的 ul 元素具有特定的 css 类?
Does anyone know how to customise the rendering of the MVC sitemap provider so my ul element has a specific css class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在 CodePlex 上托管的 MvcSiteMapProvider。您应该能够相当轻松地将现有站点地图文件迁移到略有不同但本质上兼容的格式。这将使您能够使用简单的
Html.MvcSiteMap().SiteMap()
辅助方法输出站点地图。项目的源代码包括默认模板,您可以编辑这些模板来生成您喜欢的任何渲染...或者只是根据 MVC 约定传递模板的名称。您将渲染的模型类型是
SiteMapHelperModel
、SiteMapNodeModel
和SiteMapNodeModelList
(为简洁起见,删除了命名空间)。我明白这可能不完全是您所追求的,因为它依赖于第三方工具,但它是一个有用的项目,支持的不仅仅是渲染站点地图。您需要 MVC3 版本 3.0.0。
担
Try MvcSiteMapProvider hosted on CodePlex. You should be able to fairly easily migrate your existing Sitemap file to the slightly different but essentially compatible format. This will give you the ability to output your sitemap using the simple
Html.MvcSiteMap().SiteMap()
helper method.The source of the project includes the default templates which you can edit to produce any rendering you like...or just pass in the name of a template in accordance with MVC convention. The model types you'll be rendering are
SiteMapHelperModel
,SiteMapNodeModel
andSiteMapNodeModelList
(namespaces removed for terseness).I appreciate this may not be exactly what you're after as it relies on a 3rd party tool but its a useful project that supports much more than just rendering sitemaps. You'll want version 3.0.0 for MVC3.
Dan