Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello There,
I'm currently using the Block Grid Edior and I have a Block which doesn't have and Properties.
I have Projects as a Doctype where information is stored and the blockGrid is added.
Now I want to render the informations which are on Projects in the Block but I have to get them first.
Doest anyone know how to get the Parent or the Page where the block is used, inside of the Blocks view?
You just can get a current page inside view using this code:
umbracoContextAccessor?.GetRequiredUmbracoContext() ?.PublishedRequest ?.PublishedContent
umbracoContextAccessor is instance of IUmbracoContextAccessor. This code works for Umbraco 10, but I think it's the same for 9 or 11.
IUmbracoContextAccessor
If you render block on a page, you will get actual page where it's rendered.
Thanks a lot for your answer
I solved it with ViewData and passed the Model from the view to the Block :)
It worked too, but your soltion would have been way nicer!
Im again working on a site and I hva an different question posted here: https://our.umbraco.com/forum/using-umbraco-and-getting-started/111176-umbraco-block-grid-get-parent-of-blockgridarea
Maybe you could have a look into it?
You rock thanks a lot!
You do not need to do that much work. You can simply use...
var currentPage = Umbraco.AssignedContentItem;
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get the Page of BlockGridItem
Hello There,
I'm currently using the Block Grid Edior and I have a Block which doesn't have and Properties.
I have Projects as a Doctype where information is stored and the blockGrid is added.
Now I want to render the informations which are on Projects in the Block but I have to get them first.
Doest anyone know how to get the Parent or the Page where the block is used, inside of the Blocks view?
You just can get a current page inside view using this code:
umbracoContextAccessor is instance of
IUmbracoContextAccessor
. This code works for Umbraco 10, but I think it's the same for 9 or 11.If you render block on a page, you will get actual page where it's rendered.
Thanks a lot for your answer
I solved it with ViewData and passed the Model from the view to the Block :)
It worked too, but your soltion would have been way nicer!
Im again working on a site and I hva an different question posted here: https://our.umbraco.com/forum/using-umbraco-and-getting-started/111176-umbraco-block-grid-get-parent-of-blockgridarea
Maybe you could have a look into it?
You rock thanks a lot!
You do not need to do that much work. You can simply use...
is working on a reply...