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 |
---|---|---|---|
#23 | interdiff.txt | 673 bytes | joelpittet |
#23 | 1963980-twig-views_ui-expose-filter-form-23.patch | 3.89 KB | joelpittet |
#22 | interdiff.txt | 943 bytes | joelpittet |
#22 | 1963980-twig-views_ui-expose-filter-form-22.patch | 3.9 KB | joelpittet |
#17 | interdiff.txt | 2 KB | joelpittet |
Comments
Comment #1
star-szrTagging.
Comment #2
joelpittetSplit from meta.
Comment #3
joelpittetDon't know why the tag got removed... adding it back in and removing the whitespace.
Comment #4
thedavidmeister CreditAttribution: thedavidmeister commentedThis looks good to me from a code style perspective. Ready for somebody to start manually testing the markup for :) don't forget to write out the steps for testing in the issue summary.
The only thing is that there's an awful lot of undocumented variables with @todo in this patch - are we going to open a followup ticket for these?
Comment #5
alexrayu CreditAttribution: alexrayu commentedCan't make it work in reality - the template is not getting called. 'views_ui_expose_filter_form' - is this the correct name for it? My DPM gives me the name 'views_ui_config_item_form' on the exposed filter config page.
Comment #6
joelpittet@alexrayu not sure what you mean? If you go to views for front page, and open up the filter dialog and click expose.
/admin/structure/views/view/frontpage/edit
Content: Promoted to front page status
I found some random things in the form that I don't know why they got there and added some todo cleanup.
Comment #7
tim.plunkettSee my comment in #1963978-12: Convert theme_views_ui_build_group_filter_form() to Twig, I think we should do a similar thing here.
Comment #8
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 #8.0
star-szrRemove sandbox link
Comment #9
star-szrComment #10
joelpittetUnpostpoing as there has been a while waiting, let's do this conversion for now.
Comment #11
joelpittetHere's a new patch now that we have without() filter we don't need the preprocess.
I gave it a manual test locally and it seems to work out nicely. Could use a second pair of eyes.
Comment #12
longwavePatch looks good, also manually tested successfully.
There is some code in FilterPluginBase that seems like it should belong in the template, but I guess this is a separate issue:
Comment #13
alexpottShouldn't we do?
Shouldn't these if's be the same? Looks very weird to me. That said this weirdness is in the original .tpl.php
Comment #14
joelpittet@longwave Want to give the other postponed one a go? It's very similar to this one. Likely easier to start from scratch mostly as I did here. #1963982: Convert theme_views_ui_rearrange_filter_form() to Twig
Sorry for leaving all the @todos in there.
Comment #15
joelpittet@alexpott re #13.2 I tried to match the originals.
is not empty
allows for 0's where as the second one just checks for a truthy value.The check for
{{ form.required }}
isn't needed because it doesn't have a wrapper div to concern itself with.{{ form.use_operator }}
could be a 0. Though maybe unlikely I wasn't confident in that decision. If someone else can confirm that 0's can be safely disregarded (aka !empty() vs isset()) Then I'd be glad to change it. #type was !empty() which is simply{% if var %}
Comment #16
joelpittetTried to fill out the @todos to the best of my ability (non-existent docs before).
Comment #17
joelpittetSorry that interdiff was useless, here it is again.
Comment #18
longwaveI wonder if we should just remove this template. The form structure is complicated and very variable depending on the filter in use and the various options that it may have, and I can't see why anyone would need to override this form in their theme; also it seems like it depends on a lot of #prefix and #suffix attributes that are simply hardcoded. The existing template logic can be moved to FilterPluginBase.
Also, the output already appears to be subtly broken, before this patch - edit the default Content view, click the "Published status" filter, and change "Filter type to expose" to Grouped. Perhaps this is due to the SafeMarkup feature, though.
Comment #19
joelpittetI couldn't see any difference before and after this patch. Likely don't need this template file, and that was the original intent of postponing, but I just want to get rid of the theme function. Removing this template will just further break the layout even more than it already is.
I'm fine with it being here and if someone wants to abstract it out entirely that's fine too, but the goal is just to get it converted so it's easier to maintain a a template instead of HTML in PHP strings.
The amount of drupal_renders() removed alone is a win to me.
Comment #20
longwaveIn that case I think this is fine. I am pretty sure it is safe to check
form.use_operator is not empty
in both the if statements as use_operator will either be a checkbox element or unset, never 0. However if we are going to stay with the 1:1 conversion and clean this up later, then the documentation needs a minor fix:#type belongs to operator, not use_operator.
Comment #21
longwaveI think this is ready for RTBC if we fix the minor documentation bug in #20.
Comment #22
joelpittet@longwave thanks for the poke I forgot to make the quick fix.
Comment #23
joelpittetActually I agree with it being ok to remove the
is not empty
thanks, for got that in #22Comment #24
longwaveComment #25
alexpottok let's clean this up later...
Committed 14b58a4 and pushed to 2317865. Thanks!
Comment #26
akalata CreditAttribution: akalata commentedComment #27
longwaveHuh? Not committed to 8.0.x anyway, that I can see.
Comment #28
star-szrRe-adding one of the tags for drupaltwig.org :)
Comment #29
alexpottCommitted 2ff3381 and pushed to 8.0.x. Thanks!