I am stuck. Just getting started with MVC and Umbraco at the same time, and I can't suss out how to make this happen or if I am going about it in the wrong way. Any help is appreciated.
I am trying to make a simple list of posts including link, title, media, date and summary.
What I have so far:
@{
var articles = Umbraco.Content(1216); //Node of Posts
foreach (var article in articles.Children.Where("Visible")) //Getting visible posts
{
<a href="@article.Url">
<div class="col-md-6">
<h5>@article.Name</h5>
<div><img src="/media/@article.Image/SOMETHING"/></div> <!--Gets the node of the correct media item, not sure how to get the actual file name with only the node -->
<p>@article.postDate</p>
<p>@article.summary</p>
</div>
</a>
}
}
How do I get the actual image URL associated with the article, only knowing the node id? Or is there a better way to do what I am attempting? Side request, what is the best way to format the date (show only date without time). Thanks!
Razor - getting media URL in a roundabout way?
I am stuck. Just getting started with MVC and Umbraco at the same time, and I can't suss out how to make this happen or if I am going about it in the wrong way. Any help is appreciated.
I am trying to make a simple list of posts including link, title, media, date and summary.
What I have so far:
}
How do I get the actual image URL associated with the article, only knowing the node id? Or is there a better way to do what I am attempting? Side request, what is the best way to format the date (show only date without time). Thanks!
Hi Seth and welcome to our.
You can do something like this.
Please remember to change propertyAlias so it match your field alias where you are adding your image.
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.