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
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
"Umbraco.AssignedContentItem" is a current Umbraco Page. So use just :
var page1 = Umbraco.AssignedContentItem;
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 item
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
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted