Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sonja 133 posts 621 karma points
    Nov 16, 2018 @ 07:53
    Sonja
    0

    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

    var page1 = Umbraco.Content(CurrentPage);
    

    but I'm not getting nothing. Please advice

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Nov 16, 2018 @ 08:29
    Alex Skrypnyk
    104

    Hi Sonja

    "Umbraco.AssignedContentItem" is a current Umbraco Page. So use just :

    var page1 =  Umbraco.AssignedContentItem;
    

    Alex

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Nov 16, 2018 @ 10:16
    Dave Woestenborghs
    2

    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

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft