We have moved to GitHub Issues
Created by Douglas Robar 05 Apr 2017, 09:43:54 Updated by Mikkel Holck Madsen 29 Jun 2017, 12:00:07Tags: PR
Subtask of: U4-9609
Seen in 7.6RC
All the snippets for the Partial Views and Partial View Macro Files need to be updated to use @Model.Content instead of @CurrentPage syntax.
These are located in /Umbraco/PartialViewMacros/Templates.
Not sure if there is any reason to update the ancient /Umbraco/Scripting/templates/cshtml snippets as well. Those are only for mega-old dynamics, right?
I've taken a stab at updating these files.
The changes include: @CurrentPage >>> @Model.Content .Where("Visible") >>> .Where(x => x.IsVisible()) .Content() >>> .TypedContent() .Media() >>> .TypedMedia() @item.UmbracoFile.src >>> @item.Url (see gallery.cshtml, no cropper)
The few @helper functions got updated parameter types as well: @helper Render(dynamic item) >>> @helper Render(IPublishedContent item)
Of particular note: in the gallery.cshmtl file I've moved to using @item.Url for a media image's path. Previously we had to get the .src property from the json of the UmbracoFile property. This seems a big change, though makes much more sense. Is there any reason .Url shouldn't be used in this case?
I don't have a git repo set up so will attach the updated files instead. Sorry it isn't a proper PR. Hope you don't mind. Wanted to get this updated as soon as possible.
My updates are not sufficient in light of U4-9764 and what the QueryBuilder will generate. Will need to take another stab at these.
@Per.Hansen updated the snippets further in https://github.com/umbraco/Umbraco-CMS/pull/1928. I've added comments to those that didn't have them, applied consistent spacing, added @if(selection.Any()) around output that didn't have them. Zip file attached with those edits.
@Per.Hansen + @drobar I took Douglas' new files and put them in a branch here: https://github.com/greystate/Umbraco-CMS/tree/drobar-partialviews
I see Per's PR was targeting the dev-v7.6 branch - does that mean these should be changed to use Model.PropertyAlias instead, or are PartialViews not treated the same as the "standard" views?
@greystate Thanks, my friend!
My understanding is that 7.x will use @Model.Content.PropertyAlias and that will be simplified to just @Model.PropertyAlias with v8. Would be glad to have that confirmed by @pploug (sorry, I mis-tagged my earlier comment with @Per.Hansen because it appeared in my list or users first, but that's not correct.)
Just went over the slides from the migration course again; yes - looks like you're right (from what I can gather - i.e., it's not explicitly stated but rather implied when mentioning UmbracoViewPage as "future changes").
@greystate - yes UmbracoViewPage is for V8
Ill be reviewing this today. @greystate the branch you have in your repository (the drobar-partialviews), does it have a PR on it? I has the same code changes as in the PR for this issue(https://github.com/umbraco/Umbraco-CMS/pull/1928), but also updates a few comments
@mikkelhm I'll send a PR from it, then you can see how it checks out.
Nice and thanks @greystate, that PR is merged now, Ill update with a few changes @drobar has done since these were done
Ok, everything has been merged into the dev-v7 branch, will be part of 7.6.4
We ended up merging this PR: https://github.com/umbraco/Umbraco-CMS/pull/2024 while closing the https://github.com/umbraco/Umbraco-CMS/pull/1928, as they both included the same files, adn the 2024 one had a few changes to comments.
H5YR to everyone collaborating on this issue
Priority: Task - Pri 1
Backwards Compatible: True
Affected versions: 7.6.0
Due in version: 7.6.4