Orchard CMS: getting post URL as a string

827 Views Asked by At

How do I get the URL of a certain post and an uploaded image from within the Content-BlogPost.cshtml alternate as a string?

[EDIT]

Link:

I can access the ContentItem of my blog post via Model.ContentItem.BlogPostPart.ContentItem. I can access the title and published date, via Model.ContentItem.BlogPostPart.Title and Model.ContentItem.BlogPostPart.PublishedUtc respectively. I can't find any URL field there though.

I know I can generate a link tag using @Html.ItemDisplayLink(Title, ContentItem) but I want to get the URL string as it is.

1

There are 1 best solutions below

0
On BEST ANSWER

I've found the solution is as simple as using @Url.ItemDisplayUrl(contentItem):

@{
ContentItem item = Model.ContentItem.BlogPostPart.ContentItem;
}
<a href='@Url.ItemDisplayUrl(item)'>link</a>

I will now mark this as an answer and create a new question for the media image question.