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()) { <p>@node.Content</p> }
@* Variante II *@ @foreach (var node in Model.Content.Children()) { <p>@node.Name</p> }
Variante I: node is of type Umbraco.Web.Models.DynamicPublishedContent
Variante II: node is of type Umbraco.Web.Models.XmlPublishedContent
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? :)
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
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.
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?
Comment author was deleted
Hey Tobias,
You can find some more details here: http://our.umbraco.org/documentation/Reference/Mvc/querying
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
What is better from the performance point of view?
Comment author was deleted
Model.Content
Comment author was deleted
Since DynamicPublishedContent is just a dynamic wrapper around XmlPublishedContent
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? :)
/Peter
Comment author was deleted
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
Cool. Thank you Tim. It's not all the frontenders here, who uses VS, so think CurrentPage makes more sense most the time :)
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
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.is working on a reply...