Cannot get blog post URL in BlogPost.Summary view

Topics: Customizing Orchard, Troubleshooting, Writing themes
Mar 22, 2015 at 10:08 PM
Hello,

I have custom view for my BlogPost.Summary and I am trying to access posts' urls. I can access title and other properties via "Model.ContentItem.TitlePart.Title;" for example. But URL doesn't work.

In Parts.Blogs.RecentBlogPosts view I can access the URL with string postUrl = Url.ItemDisplayUrl((ContentItem)post.ContentItem); but this approach throws compilation error when using on BlogPost.Summary....

Shape Tracking also won't help, I just cannot find URL in Model section...

Thanks.
Mar 23, 2015 at 1:18 AM
Edited Mar 23, 2015 at 1:21 AM
Hi,

You can access the post URL from the autoroute content part like so:
@{
    url = "~/" + Model.ContentItem.AutoroutePart.Path.ToString();
}
Then the usage will be as follows:
<a href="@Href(url)"></a>
Hope this helps,
Ryan
Mar 23, 2015 at 7:59 AM
Thanks Ryan, this works.