I'm using Umbraco 10 and in a BlockList item I need to display some "Related posts" which basically is another page / node.
The Related content is blog postes
I'm using the "Multinode TreePicker" to choose the blog posts.
So far so good – I can get various things like Url, Id, etc.
(In my BlockListItem)
var content = Model.Content as BlogPost;
var relatedPosts = content.RelatedPosts;
foreach (var relatedPost in relatedPosts)
{
var url = relatedPost.Url();
var relatedName = relatedPost.Name;
var relatedId = relatedPost.Id;
}
But how can I get the contents of the blog post? E.g. a Textstring (Umbraco.Textbox) named "blogName"
In my head, it would be logic just to write:
@relatedPost.BlogName
or maybe
@relatedPost.content.BlogName
But it all fails. 😕
I think I lack some basic understanding of the docs 😅
Can someone please help me in the right direction?
Wow.. Okay! I spend the whole day yesterday searching for a solution and it turned out to be that simple.
(Now In my BlockListItem)
var content = Model.Content as BlogPost;
foreach (BlogPage relatedPost in content.RelatedPosts)
{
var url = relatedPost.Url();
var relatedName = relatedPost.Name;
var relatedId = relatedPost.Id;
var blogName = relatedPost.BlogName;
}
Get content from another page / node
I'm using Umbraco 10 and in a BlockList item I need to display some "Related posts" which basically is another page / node.
The Related content is blog postes
I'm using the "Multinode TreePicker" to choose the blog posts. So far so good – I can get various things like Url, Id, etc.
But how can I get the contents of the blog post? E.g. a Textstring (Umbraco.Textbox) named "blogName"
In my head, it would be logic just to write:
or maybe
But it all fails. 😕
I think I lack some basic understanding of the docs 😅
Can someone please help me in the right direction?
you'll need to cast your items similar to below
obviously your types will be different
Wow.. Okay! I spend the whole day yesterday searching for a solution and it turned out to be that simple.
Thanks Huw!
is working on a reply...