Copied to clipboard

Flag this post as spam?

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

  • Tobias Morf 80 posts 183 karma points
    Jun 19, 2013 @ 11:41
    Tobias Morf

    CurrentPage vs. Model.Content

    Can someone point out what should be used within a Partial View Macro Files?
    Should I use "CurrentPage" or "Model.Content"?
    What are the advantages and disadvantages?

    @* Variante I *@
    @foreach (var node in CurrentPage.Children()) {
    } @* Variante II *@
    @foreach (var node in Model.Content.Children()) {
    Variante I: node is of type Umbraco.Web.Models.DynamicPublishedContent
    Variante II: node is of type Umbraco.Web.Models.XmlPublishedContent
  • Comment author was deleted

    Jun 19, 2013 @ 11:48

    Hey Tobias,

    You can find some more details here:

    CurrentPage is a dynamic object so the syntax will be shorter but some complex queries might not be doable with that type of object

    Model.Content is strongly types so when you are in visual studio you can take advantage of the intellisense 

  • Tobias Morf 80 posts 183 karma points
    Jun 19, 2013 @ 11:56
    Tobias Morf

    What is better from the performance point of view?

  • Comment author was deleted

    Jun 19, 2013 @ 11:59


  • Comment author was deleted

    Jun 19, 2013 @ 12:03

    Since DynamicPublishedContent is just a dynamic wrapper around XmlPublishedContent

  • Peter Nielsen 159 posts 257 karma points
    Feb 04, 2014 @ 08:40
    Peter Nielsen

    Sorry to bring back such an old thread, but is there any performance tests to show the difference between Model.Content and CurrentPage? What is best practice? What do you guys use? :)


  • Comment author was deleted

    Feb 04, 2014 @ 10:19

    If you dev in vs and want to take advantage of intellisense use Model.Content, if you don't care about that and just want the shortest syntax use CurrentPage

  • Peter Nielsen 159 posts 257 karma points
    Feb 04, 2014 @ 10:27
    Peter Nielsen

    Cool. Thank you Tim. It's not all the frontenders here, who uses VS, so think CurrentPage makes more sense most the time :)

  • Borjan 1 post 21 karma points
    Apr 07, 2014 @ 18:26

    Hi guys, I dont know if this is the right place to ask this but i will give it a go. I have been trying to use the new image cropper in umbraco 7.1 and all of the documentation uses @CurrentPage. This is all fine but when i try and use @CurrentPage in a razor macro, it gives back an error saying CurrentPage doesnt exist in current context. I have been trying to somehow use @Model.Content but this doesnt give back any result.

    Thanks a lot

  • Damien (Slipoch) 62 posts 346 karma points
    Jun 14, 2017 @ 23:58
    Damien (Slipoch)

    Do you have the usings for the page at the top?

    A macro page should be mostly self-contained, ie: no reference to dynamics like @currentpage.

    Just take in info through the macro interface.

    your img src can use the cropper dynamically by adding ?cropmode=... withing the src call.

    Otherwise you could use @item.GetCrop(...) in src.

Please Sign in or register to post replies

Write your reply to: