Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Comment | File | Size | Author |
---|---|---|---|
#35 | 1912606-35-twig-theme-views-view-grouping.patch | 1.44 KB | joelpittet |
#35 | interdiff.txt | 3.37 KB | joelpittet |
#30 | 1912606-30.patch | 4.25 KB | jastraat |
#30 | interdiff.txt | 1.73 KB | jastraat |
#27 | views.view_.test.zip | 1002 bytes | jastraat |
Comments
Comment #1
gollyg CreditAttribution: gollyg commentedSubmitting an initial patch, but not able to test due to #1913718: Aggregation settings link generates AJAX error..
Comment #2
gollyg CreditAttribution: gollyg commentedand the patch...
Comment #3
gollyg CreditAttribution: gollyg commentedAdding full stop to comment and new line at the end of the file.
Comment #4
dawehnerThanks for the patch!
We should explain what this content is about. (the rendered style of the grouped view, or something like that).
What about mention the ViewExecutable object somehow here?
Maybe also @see for \Drupal\views\Plugin\views\style\StylePluginBase::render_grouping_sets()
Comment #5
gollyg CreditAttribution: gollyg commentedNp providing the patch :)
Have made some changes based upon the suggestions. A couple of points:
Comment #6
gollyg CreditAttribution: gollyg commentedComment #7
joelpittetComment #8
jastraat CreditAttribution: jastraat commentedComment #9
jastraat CreditAttribution: jastraat commentedComment #10
joelpittetThanks @jastraat, looks great just added a few nitpicks.
Can you drop the $'s in the twig docblock?
That probably shouldn't be in there.
Comment #11
dawehnerI'm not against putting this in here, because it has the potential for people to understand where this is called, but yeah I don't care much whether it should stick or not.
I'm quite sure that this piece is wrong. The elements of variables are view, title, content, rows and grouping_level
Comment #12
jastraat CreditAttribution: jastraat commented@dawehner - If the $hook for views_view_grouping is no longer be necessary in views_theme with the removal of the theme function that was used instead of a template, ( See https://drupal.org/node/1843746#comment-7271612 ) then that change to views.module should probably be a part of this patch as well. Could you comment?
Thanks!
Comment #13
dawehnerNo it's still needed. Should we let users test this manually?
Comment #14
jastraat CreditAttribution: jastraat commentedI tested it in an installation of Drupal 8, but it never hurts to have other users try it. I've attached an updated patch with the changes from #10 and #11
Comment #15
star-szrThanks @jastraat! I think this is looking good. Minor documentation nitpicks ahead :)
This needs to be a complete sentence (end in a period) per http://drupal.org/node/1354#drupal.
Over 80 characters, please wrap (ref. same link as above).
Comment #16
jastraat CreditAttribution: jastraat commented@Cottser - Sorry I missed the 80 character limit: I'll fix that.
Almost none of the variable descriptions are full sentences though; some of them are just longer fragments.
Comment #17
star-szr@jastraat - thanks, good point! Feel free to tweak the variable documentation, please include an interdiff. A few more documentation updates I noticed:
These need to end in parens per http://drupal.org/node/1354#see, i.e. @see template_preprocess().
Per #1913208: [policy] Standardize template preprocess function documentation this should end in "templates", but I'd recommend splitting up the description a bit, something like:
I think maybe we need another example in #1913208: [policy] Standardize template preprocess function documentation, the current example there only shows a render element, whereas this one has many variables being passed in.
In this case it should be listing all the same variables as the template does (in almost exactly the same format), minus content. #1898460-6: taxonomy.module - Convert PHPTemplate templates to Twig has a good example of this.
Comment #18
jastraat CreditAttribution: jastraat commentedComment #19
star-szrThanks @jastraat, the changes look good and the interdiff was very helpful! A couple minor tweaks, the first to the Twig template and the second to the preprocess docblock:
This will still need a period at the end.
This is *just* over 80 characters, please wrap "grouping." to the next line.
Comment #20
jastraat CreditAttribution: jastraat commentedComment #21
jastraat CreditAttribution: jastraat commentedRemoved trailing space.
Comment #22
dawehnerThis seems to be perfect.
Comment #23
star-szrCode looks good, I just closed #1843752: Convert views/templates/views-view-grouping.tpl.php to twig as a dupe.
Comment #24
star-szrI did manual testing and the markup didn't show up. Adding 'template' gets better results, but I'd like someone else to confirm the markup is as expected. I was getting errors like the following before I applied the patch, so the output was actually quite a bit different after applying the patch (more rows were output after patching):
Notice: Array to string conversion in theme_views_view_grouping() (line 308 of core/modules/views/views.theme.inc).
I'd attach a view export but I guess I haven't really kept up with how that works in D8 :)
I created a view of nodes displaying fields, kept the default title field and added a "published status" field, then set "published status" as the #1 grouping field and "title" as the #2 grouping field.
Comment #25
star-szrAlso if I'm not mistaken we should remove the 'pattern' key like we did in #1843746: Convert views/templates/views-view-field.tpl.php to Twig , discussed in #22 and #23 there.
Comment #26
jastraat CreditAttribution: jastraat commentedI did manually test the patch from #21, and I didn't get the error you mentioned. However, I also don't think the template is being picked up. I created a unformatted list view of nodes grouped by publication year, and it appears that it's using the views-view-unformatted.tpl.php template. This was the case even after I added 'template' and removed 'pattern' from the views_theme() function.
Does anyone know exactly when the grouping template gets called?
Comment #27
jastraat CreditAttribution: jastraat commentedIs the way to export a view now to grab the .yml file from files/config_* ?
For example - see attachment of the view I mentioned in #26.
Comment #28
star-szrThe error was actually before I applied the patch. As far as I can tell, you need to add two groupings for this template to be used.
Comment #29
thedavidmeister CreditAttribution: thedavidmeister commentedNitpick for #24 - Could we capitalise "V" for a View when you're referencing a View object?
Comment #30
jastraat CreditAttribution: jastraat commentedUpdated with comments from #25 and #29. Unfortunately I wasn't able to manually test this because the most up-to-date pull of Drupal 8 just crashes on my local installation.
Comment #31
jastraat CreditAttribution: jastraat commentedComment #32
star-szr@jastraat - for the manual testing/fixing broken Drupal 8 you might try removing sites/default/files/php and truncating all your cache tables, that often helps. If not, dump your database, copy default.settings.php over settings.php and re-install Drupal 8.
Comment #33
jastraat CreditAttribution: jastraat commented@Cottser - I'm afraid I've tried both those methods already. Drupal 8 installs, but then immediately logs out the first user. Every time I try to load the site, the connection is reset. Note - I have a Drupal 7 site on this same installation of WAMP and am NOT having connection reset problems. I also wasn't having this problem with the Drupal 8 install prior to this week.
Comment #34
dawehnerJust by looking at the error message I would say that's fine, because you removed the code which produces the error message anyway.
Comment #34.0
dawehnerUpdated issue summary.
Comment #35
joelpittetThis is now just remove the theme function. The tpl conversion is this way -> #1843752: Convert views/templates/views-view-grouping.tpl.php to twig
Comment #36
joelpittetTitling as this now just removes the theme_ function.
Comment #37
dawehnerThis looks perfect.
Comment #38
alexpottCommitted 1304f13 and pushed to 8.x. Thanks!
Comment #39.0
(not verified) CreditAttribution: commentedUpdated issue summary.