U4-9727 - Update partial view snippets to Model.Content from CurrentPage

Created by Douglas Robar 05 Apr 2017, 09:43:54 Updated by Mikkel Holck Madsen 29 Jun 2017, 12:00:07

Tags: 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?

1 Attachments

Download PartialViewMacros-Templates.zip

Comments

Douglas Robar 11 Apr 2017, 13:07:02

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.


Douglas Robar 02 May 2017, 12:57:25

My updates are not sufficient in light of U4-9764 and what the QueryBuilder will generate. Will need to take another stab at these.


Douglas Robar 03 May 2017, 11:06:47

@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.


Chriztian Steinmeier 05 May 2017, 22:02:40

@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?


Douglas Robar 07 May 2017, 13:36:08

@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.)


Chriztian Steinmeier 08 May 2017, 17:06:14

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").


Per Ploug 11 May 2017, 11:45:13

@greystate - yes UmbracoViewPage is for V8


Mikkel Holck Madsen 29 Jun 2017, 07:54:09

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


Chriztian Steinmeier 29 Jun 2017, 10:44:12

@mikkelhm I'll send a PR from it, then you can see how it checks out.


Chriztian Steinmeier 29 Jun 2017, 10:47:52

PR here: https://github.com/umbraco/Umbraco-CMS/pull/2024


Mikkel Holck Madsen 29 Jun 2017, 11:52:48

Nice and thanks @greystate, that PR is merged now, Ill update with a few changes @drobar has done since these were done


Mikkel Holck Madsen 29 Jun 2017, 11:59:55

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

Type: Bug

State: Fixed

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.6.0

Due in version: 7.6.4

Sprint:

Story Points:

Cycle: 2