Cannot get blog post URL in BlogPost.Summary view

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

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...

Mar 23, 2015 at 12:18 AM
Edited Mar 23, 2015 at 12:21 AM

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,
Mar 23, 2015 at 6:59 AM
Thanks Ryan, this works.