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
Convert theme_ functions to Twig templates.
Remaining
theme_ function -> Twig conversions (and preprocess function additions or changes) moved over from the existing conversion issueReroll- Manual testing (markup comparison)
- Patch review
- Profiling
Theme function name | Conversion status |
---|---|
theme_node_add_list | converted |
theme_node_admin_overview | |
theme_node_preview | converted |
theme_node_recent_block | |
theme_node_recent_content | |
To test this code
- Navigate to
node/add
to see if node-add-list.html.twig is working - Preview the node to see if node-preview.html.twig is working
Related Issues
#1898432: node.module - Convert PHPTemplate templates to Twig
#1757550: [Meta] Convert core theme functions to Twig templates
#1987510: [meta] Convert all core *.tpl.php templates to Twig as singular patch
Comment | File | Size | Author |
---|---|---|---|
#68 | 1987406-68-twig-node-theme.patch | 6.34 KB | idflood |
#56 | node-preview.php_.txt | 4.07 KB | Petr Illek |
#56 | node-preview.twig_.txt | 4.1 KB | Petr Illek |
#56 | recentcontent.php_.txt | 1.11 KB | Petr Illek |
#56 | recentcontent.twig_.txt | 1.12 KB | Petr Illek |
Comments
Comment #0.0
star-szrUpdated issue summary.
Comment #1
c4rl CreditAttribution: c4rl commentedPer #1757550-44: [Meta] Convert core theme functions to Twig templates, retitling to indicate this issue applies to theme_ functions rather than templates. See #1898432: node.module - Convert PHPTemplate templates to Twig for template conversion.
Comment #1.0
c4rl CreditAttribution: c4rl commentedUpdated issue summary.
Comment #1.1
c4rl CreditAttribution: c4rl commentedAdded list of functions
Comment #2
shanethehat CreditAttribution: shanethehat commentedComment #3
shanethehat CreditAttribution: shanethehat commentedComment #5
shanethehat CreditAttribution: shanethehat commented#3: twig-node-theme-only-1987406-3.patch queued for re-testing.
Comment #6
jstoller#3: twig-node-theme-only-1987406-3.patch queued for re-testing.
Comment #7
ericaack CreditAttribution: ericaack commentedI'll do the manual testing here at the Drupalcon code sprint.
Comment #8
dflitner CreditAttribution: dflitner commentedTesting patch in #3:
I added some text in the .twig files to confirm that these files are being used.
These are the files I received:
node.html.twig - can't confirm this is working and I'm not sure where to check. My test text isn't visible on node view
node-add-list.html.twig - can't confirm this is working, my test text isn't visible when adding a list field to a content type or when creating a new page and editing a list field or on the node/add page for any content type
node-admin-overview.html.twig is working. (Shows once per content type)
node-edit-form.html.twig is working.
node-preview.html.twig seems to add in the previews twice (screenshot)
node-recent-block.html.twig is working.
node-recent-content.html.twig is working (once per node)
I took a quick look at node-preview.html.twig and node-edit-form.html.twig and I don't see why the Preview would be appearing twice.
My first patch test and at the DrupalCon sprint :)
Please let me know if I can provide more information.
Comment #9
ernie-g CreditAttribution: ernie-g commentedprofiling...
Comment #10
ernie-g CreditAttribution: ernie-g commentedComment #11
rwohlebComment #12
Jon PughGot node-add-list.html.twig working...
Comment #13
Jon PughOops cross posted. but on second thought...
Can we even profile this if the templates aren't being used yet?
Comment #14
Jon Pughnode.html.twig seems to work too...
Comment #15
Jon PughManually went through the test process...
The last task here looks like node-search-admin.html.twig
Comment #16
ernie-g CreditAttribution: ernie-g commentedMANY APOLOGIES
It turns out, the profiling instructions I received at the DrupalCon Code Sprint was incomplete.
I am going to be re-running all my profiling :-/
Comment #17
Jon PughSo the last theme_function to kill here is theme_node_search_admin()
This one is tricky because it has a table in it.... @bradwade and I think maybe a table isn't the best way to do this, but either way... I do not know enough about twig to figure out how to render a form in a table!
So... code sprints over... needs work :)
P.S. @ernie-g No worries! Gotta start somewhere, right? :D
Comment #18
ernie-g CreditAttribution: ernie-g commentedMANY APOLOGIES
It turns out, the profiling instructions I received at the DrupalCon Code Sprint was incomplete.
I am going to be re-running all my profiling :-/
Comment #19
ezeedub CreditAttribution: ezeedub commentedResubmitting the patch in #10 to kick the test bot into gear (pls tell me if there's a better way to do that).
Comment #20
Jon PughIf we can de-scope this issue to remove theme_node_search_admin (which has it's own issue anyway #1938920: Convert node_search_admin theme tables to table #type) than this is ready to be RTBC'd by someone.
#1938920: Convert node_search_admin theme tables to table #type is close to done, but its also not a twig issue at all, so there's another argument to call this one (ready to be called) done...
Comment #21
joelpittet@Jon Pugh re: #20 that type table conversion is not in the patch and is called out in the summary to not convert it, am I missing something?
Also, what's up with the CSS change of adding the dl selector, is that needed? That looks like it's part of the seven theme conversion and should probably make it's way over to that or separate issue.
Comment #22
jenlampton@ezeedub there is a link on the very right of each patch that reads "Re-test". Click that link if you want to retest a patch, no need to upload something that's not-quite the same :)
reuploading #10
Comment #24
jenlamptonwhooboy did that need a reroll. Trying again.
Comment #26
jenlamptonduh
Comment #27
star-szr@ezeedub and @jenlampton - I think you are talking about the patch in #12, which is yellow with no Re-test link. It was one of the unlucky patches that got caught in limbo around DrupalCon Portland.
Thanks for the fresh patch @jenlampton, and it's green!
Comment #28
sanguis CreditAttribution: sanguis commented#26: twig-node_convert-1987406-26.patch queued for re-testing.
Comment #30
sanguis CreditAttribution: sanguis commentedrerolled patch from #26
Comment #32
joelpittet@Jon Pugh
seven_node_add_list should be taken care of here:
#1987424: seven.theme - Convert theme_ functions to Twig
Along with the CSS change if needed, which I also reverted (needs a new issue or or if needed for conversion then move it there as well.)
Removed the
@see template_preprocess()
from the twig files.There seemed to be a language module change from $language_content->langcode to $language_content->id so I reverted those changes.
Also reverted a change from ->nid to ->id() because there is another issue open for that and there a few more in node.module that need conversion.
Comment #33
joelpittetand go
Comment #34
joelpittetAdding profiling back.
Comment #35
jerdavisComment #36
jerdavisFirst profiling run for this patch. This is of the node/add page
Scenario:
- Have 10 content types with descriptions
- Give Anonymous role all permissions
- Set home page to node/add
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec3b81ad265&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec3b81ad265&...
Comment #37
jerdavisProfiling of Recent Content block
Scenario:
- Recent content block in content region
- 50 nodes generated
- Front page display showing only 1 node
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec485525502&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec485525502&...
Comment #38
jerdavisProfiling of Preview
Scenario -
- Custom module adds a callback to preview node 1 at /preview
- Make sure there's a node 1
- See files for the module
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec517fc2424&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=51ec517fc2424&...
Comment #39
jerdavisAbove I've profiled the 3 functions included in this patch.
The template for theme_node_admin_overview is no longer invoked, as the Admin Overview of content types has been switched to separate table columns for type and description.
theme_node_search_admin is not included in the patch.
Given the change to admin overview, here's a re-roll of #32 removing that extra twig template.
Comment #41
star-szrThanks for all your work on this @jerdavis! I tried to apply the patch locally (
git apply -v --check
) and got this:So everything applies but there is a hidden .swp file that got included in the patch unintentionally that is throwing things off.
Comment #42
jenlamptonrerolled as per #41
Comment #44
star-szr#42: twig-convert_node-1987406-42.patch queued for re-testing.
Comment #45
star-szrTime for another reroll.
Comment #46
herom CreditAttribution: herom commentedRerolled.
Comment #47
herom CreditAttribution: herom commentedchanging status.
Comment #49
star-szr#46: twig-convert_node-1987406-46.patch queued for re-testing.
Comment #49.0
star-szrCorrect testing steps
Comment #50
joelpittetDid my first git bisect to find out who got rid of
theme_node_admin_overview
Updated issue summary: Removed from #111715: Convert node/content types into configuration: Convert node/content types into configuration
Removed the extra image.html.twig template that snuck in there and cleaned up the preprocess comments to remove the @see template_preprocess_* because that is not done anywhere else in core and is a bit unclear of what it does.
Comment #51
joelpittetWe could really simplify this template one of 3 ways.
Thoughts?
Other than that, I think this is RTBC.
Comment #52
BerdirAccidental revert of using getChangedTime()
Comment #53
joelpittetThanks for spotting that @Berdir!
Comment #54
star-szrI'm not really seeing any manual testing completed here, so tagging for the Twig sprint in Prague.
Comment #55
Petr IllekJust working on it. @drupalcon
Comment #55.0
Petr IllekUpdated issue summary.
Comment #55.1
Petr IllekThe work is being done in another issue.
Comment #55.2
Petr IllekThe work is being done in other issue.
Comment #56
Petr IllekI've check if the twig templates are used - see the updated conversion table on top.
There are still some minor differences in the markup – see attached txt files with samples.
Comment #57
star-szrThanks a lot @Petr Illek! So we do need some more work here to get the markup matching up.
Comment #57.0
star-szrUpdated the conversion status table
Comment #58
joelpittet53: 1987406-53-twig-node-theme.patch queued for re-testing.
Comment #59
longwaveNot sure this will work as expected - the non-Twig version compared the drupal_render() output instead of the original render array. Additionally, $variables['teaser']['#attached'] will be set by the above block, and $variables['full']['#attached'] is unlikely to include the drupal.node.preview library.
Having said that, I wonder if this has ever worked as expected, because it's likely that the rendered output will at least contain different HTML classes for the full and teaser versions, isn't it?
Comment #60
star-szrTagging for reroll.
Comment #61
forbesgraham CreditAttribution: forbesgraham commentedRerolling patch from comment 53.
Comment #62
joelpittet@forbesgraham thanks for the re-roll.
'admin-list' class shouldn't be here as per #56
Not sure about that extra visually-hidden class on preview... may need a re-test.
node_search_admin is to be possibly taken care of through #type=>table or possibly something else...
@longwave I think you're right, it may need to be still passed through drupal_render and we should confirm the output comparison is doing what is meant to. (crosses fingers for #1510544: Allow to preview content in an actual live environment to pull through)
Comment #63
joelpittetComment #64
xjm(Merging "node system" and "node.module" components for 8.x; disregard.)
Comment #65
star-szrThanks to @dawehner for the heads-up, #2020393: Convert "Recent content" block to a View will be removing theme_node_recent_block() and theme_node_recent_content() so let's back out those conversions please since they are going away :)
Comment #66
joelpittetRe-rolled, removed those recent block/content conversions and added a trans block for the longer text.
Comment #67
star-szrUpdating the issue summary, tagging for reroll, and calling dibs for the Drupal sprint happening as part of Drupal Global Sprint Weekend in London Ontario.
Comment #68
idflood CreditAttribution: idflood commentedSimple reroll of patch in #66
Comment #69
star-szrThanks @idflood. I started work on manual testing (markup comparison) and profiling so I'm assigning until I finish that up. We do have some profiling results starting in #36 but that was almost 6 months ago and the patch (and core) have changed enough that it's worth running through again. Not bad now since there are only two templates to profile!
Comment #70
star-szrComment #71
star-szrMarkup matches up perfectly (other than whitespace of course), and performance looks quite comparable. I think this one's ready to go!
/node/add (2 content types)
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5c0b2e882a&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5c0b2e882a&...
/node/add (10 content types)
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5c520502f0&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5c520502f0&...
Node preview
(tested using /twig/node-preview from https://drupal.org/sandbox/cottser/2191591)
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5cb0964fa0&...
http://www.lionsad.de/xhprof-kit/xhprof/xhprof_html/?run1=52f5cb0964fa0&...
Comment #72
star-szr68: 1987406-68-twig-node-theme.patch queued for re-testing.
Comment #75
star-szr68: 1987406-68-twig-node-theme.patch queued for re-testing.
Comment #76
star-szrIt was just #2188897: Intermittent fails in Drupal\views_ui\Tests\DisplayTest.
Comment #77
alexpottCommitted 5e112d8 and pushed to 8.x. Thanks!