Copied to clipboard

Flag this post as spam?

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


  • Sonja 123 posts 591 karma points
    Nov 16, 2018 @ 07:53
    Sonja
    0

    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 5363 posts 19800 karma points MVP 3x admin c-trib
    Nov 16, 2018 @ 08:29
    Alex Skrypnyk
    101

    Hi Sonja

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

    var page1 =  Umbraco.AssignedContentItem;
    

    Alex

  • Dave Woestenborghs 3214 posts 10805 karma points MVP 4x admin c-trib
    Nov 16, 2018 @ 10:16
    Dave Woestenborghs
    1

    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