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.
Task
Use Twig instead of PHPTemplate
Remaining
- Replace all tpl.php files with .html.twig equivalents
- Replace all theme functions with .html.twig equivalent templates
- Add new preprocess functions for the .html.twig equivalent templates
- Update all hook_theme definitions
Related Issues
#1898472: [meta] Convert views_ui module to Twig
#1757550: [Meta] Convert core theme functions to Twig templates
Comment | File | Size | Author |
---|---|---|---|
#27 | views-filter-reorder-elements.png | 182.35 KB | joelpittet |
#27 | views-ui-reorder-filters-top.png | 257.98 KB | joelpittet |
#27 | 1963982-twig-views-ui-rearrange-filter-form-27.patch | 9.61 KB | joelpittet |
#27 | interdiff.txt | 1.04 KB | joelpittet |
#26 | 1963982-twig-views-ui-rearrange-filter-form-26.patch | 9.61 KB | lauriii |
Comments
Comment #1
star-szrTagging.
Comment #2
joelpittetSplit from meta.
Comment #4
joelpittetwhoops, removed a '+'
Comment #5
thedavidmeister CreditAttribution: thedavidmeister commentedReview for #4:
+ * Default theme implementation for views ui rearrange filter form.
Views UI
+ * - grouping: A boolean for if there is more than one group.
We're not including PHP data types in Twig template docs.
Does this really work? $instructions would be a string and presumably $form['remove_groups'][$group_id] is a renderable array, right?
+ '#theme' => 'link',
We're not supposed to be doing this unless #1922454: Gut l(), fix theme('link'), have a working framework for consistently generated links inside and outside of Twig lands. Don't know if we need to change anything, but it's worth noting that this patch is essentially waiting on that.
Shouldn't the div be indented two spaces?
This issue needs manual steps for testing to be added to the issue summary and for somebody to follow the steps and verify the markup manually.
Comment #6
star-szrThanks @thedavidmeister. I think the div is fine, it's not inside any Twig tags. I agree about the render array, the separate strings (or whatever they are) can probably be converted to an array inside 'data' (with weights if needed) instead of concatenating.
Comment #7
joelpittetYeah that $instructions concatenation was a blunder thanks @thedavidmeister
Left theme link conversion because it's only really active links that are affected there. Let me know if my assumption is wrong?
Comment #9
joelpittethmmm, how did that get in there, fixed array line length as well.
Comment #11
joelpittet#9: 1963982-9-twig-views-ui-rearrange-filter-form.patch queued for re-testing.
Comment #12
thedavidmeister CreditAttribution: thedavidmeister commented#7 -
Currently theme_link() skips the active class handling and also this sanitization:
Comment #13
tim.plunkettNormally in render arrays we use
'#type' => 'link'
Otherwise, this looks great!
Comment #14
thedavidmeister CreditAttribution: thedavidmeister commented#13 - '#type' => 'link' is for form elements I thought.
Comment #15
tim.plunkettNo, it's a render element. All render elements are also form elements, but they can be used on their own. #type => container, for example.
Comment #16
star-szrIt sounds like this will likely be converted in a similar manner to #1984850: Convert FilterPluginBase::build_group_form to use table rendering and remove theme function, postponing until we have an issue created for that separate conversion.
Comment #16.0
star-szrRemove sandbox link
Comment #17
star-szrComment #18
joelpittetUnpostpoing as there has been a while waiting, let's do this conversion for now.
Comment #19
lauriiiComment #20
lauriiiComment #21
joelpittet@lauriii have a look at #1963980: Convert theme_views_ui_expose_filter_form() to Twig Would you mind doing the same here? Removing the preprocess entirely if possible, and attempt at filling out the @todos?
Comment #22
lauriiiYeah, I'll take look on that.
Comment #23
joelpittetThanks @lauriii here's the changes since #20
Mind doing an manual testing?
Comment #24
joelpittetThis fixes at least the remove button to show up because #theme link doesn't exist but #type link does.
For some reason the the action buttons have an extra "Create new filter group". I'm not really sure why at the moment...
This patch fixes all of the Twig autoescaping issues with this theme. See screenshot.
@laurii Want to take a stab at getting that action link to do what it did before (I assume hide or JS hide...)
And maybe a markup comparison?
Comment #25
lauriiiThe patch applied here solves issue described on #24.
I did markup comparison and found few differences:
1) Default group filter is visible all the time because its missing
.tabledrag-hide
. Patch applied here should fix this.Before:
After:
2)
.views-messages
element is visible even if there's no messages.Create new filter group functionality doesn't work for some reason, so I couldn't test what happens when there's multiple groups.
Comment #26
lauriii@joelpittet found some more changes on the markup so here's a fix for them:
1) Empty markup have changed so I rolled it back for how it used to be.
2) Elements on the remove col wasn't arranged correctly.
Comment #27
joelpittetOk so we fixed the escaping issues with this function, which is a plus.
I manually fixed the before patch markup
> <
to accurately to a comparison.@lauriii fixed the minor ordering issue with a #weight and and the empty markup was moved back to where it was because #empty didn't seem to work on the #type table so no need to make that change in this conversion issue.
I've just added a couple minor changes still, removed Javascript:void() from the link to match and got #instructions to show up in the markup with #markup.
Markup Review Screenshots:
Comment #28
star-szrAdding a related issue for the existing filter group bug.
Comment #29
webchickCommitted and pushed to 8.x. Thanks!