我用Orchard CMS 1.10.1。在我的主题中,我有一个BlogPost detail display type的备用视图。
在这个视图中,我需要title和url的博客,它是这个BlogPost的父级,在这个备用目录中。
我怎样才能做到这一点?
发布于 2017-04-06 08:26:35
如果您查看BlogPostPart的模型,BlogPart。通过使用它,您可以获得标题:
@using Orchard.Utility.Extensions
@{
ContentItem contentItem = Model.ContentItem; // Cast to ContentItem
var blogPostPart = contentItem.As<BlogPostPart>(); // Get BlogPostPart
var blogPart = blogPostPart.BlogPart; // BlogPart is a property on BlogPostPart
var blogTitle = blogPart.Name; // Get the name of the blog part
}要获取博客的url,可以使用博客的模块url助手
@using Orchard.Blogs.Extensions;
@using Orchard.Blogs.Models;
@{
var blogPart = (BlogPart)Model.Blog;
}
<a href="@Url.Blog(blogPart)">@blogPart.Name</a>https://stackoverflow.com/questions/43249486
复制相似问题