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
Hi,
How do I get Current Page in partial view? I wouldn't like to loop thru Model.Content.Site because I want to avoid loop. I've tried
var page1 = Umbraco.Content(CurrentPage);
but I'm not getting nothing. Please advice
Hi Sonja
"Umbraco.AssignedContentItem" is a current Umbraco Page. So use just :
var page1 = Umbraco.AssignedContentItem;
Alex
Depends on what kind of view type you are using
If your template inherits from UmbracoViewPage than @Model is your current item.
UmbracoViewPage
@Model
If your template inherits from UmbracoTemplatePage than @Model.Content is your current item
UmbracoTemplatePage
@Model.Content
But if you use a custom model eg. UmbracoViewPage
If you are interested in what the difference is between UmbracoViewPage and UmbracoTemplatePage you can read this article : https://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/
Be aware that in V8 UmbracoTemplatePage does not exist anymore so it's better to use UmbracoViewPage
Personally I also use ModelsBuilder to create strongly typed object representing my documenttypes.
You can read more about that here ; https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
If you have more questions just let us know
Dave
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get current page
Hi,
How do I get Current Page in partial view? I wouldn't like to loop thru Model.Content.Site because I want to avoid loop. I've tried
but I'm not getting nothing. Please advice
Hi Sonja
"Umbraco.AssignedContentItem" is a current Umbraco Page. So use just :
Alex
Depends on what kind of view type you are using
If your template inherits from
UmbracoViewPage
than@Model
is your current item.If your template inherits from
UmbracoTemplatePage
than@Model.Content
is your current itemBut if you use a custom model eg. UmbracoViewPage
If you are interested in what the difference is between UmbracoViewPage and UmbracoTemplatePage you can read this article : https://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/
Be aware that in V8 UmbracoTemplatePage does not exist anymore so it's better to use UmbracoViewPage
Personally I also use ModelsBuilder to create strongly typed object representing my documenttypes.
You can read more about that here ; https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
If you have more questions just let us know
Dave
is working on a reply...