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.
See #1880976: [meta] Port examples (including submodules) to D9.4+
This will probably help to fix the problem at #1883728: Port theming_example to D8
Comment | File | Size | Author |
---|---|---|---|
#34 | interdiff.txt | 1.01 KB | Mile23 |
#34 | 1889842_34.patch | 62.82 KB | Mile23 |
| |||
#32 | 1889842_32.patch | 62.81 KB | Mile23 |
#30 | interdiff.txt | 1.81 KB | eojthebrave |
#29 | 1889842-29-eojthebrave_render_example.patch | 62.83 KB | eojthebrave |
Comments
Comment #1
marvil07 CreditAttribution: marvil07 commentedHere the base version, tests running(not passing, NR only for testbot).
Pending to ask/figure out: testing profile theme does not seem to have standard regions, or maybe we need another step at blocks to let them appear. i.e. How to assert a text on a block? (how to show a block programatically?)
Comment #3
jlbellidoI'll start working here. Firstly updating #1 to the current version of drupal 8, then I'll continue improving this example.
Comment #4
jlbellidoHello!
After a little bit of work I updated the previous patch to the current versión of D8, basically that are the changes:
Tests still failing :( . Because we haven't available hook_page_alter anymore (https://www.drupal.org/node/2357755). I think we should move that example (Altering example) placing the render arrays into the header using (https://api.drupal.org/api/drupal/core!modules!system!theme.api.php/func...) or same with the button.
What do you think?
Thanks!
Comment #6
damontgomery CreditAttribution: damontgomery commentedThanks, jlbellido and marvil07. I've resumed work from the progress in #4. So far I've gone through the description page (to use a render array for lists) and the arrays page. I plan on tackling the hooks through the end of this week. I've been trying to leave a lot of comments.
I found the original example odd since it didn't use the render array structure in the code, but rather, used a custom object that was then processed into a render array. I've updated this part.
There was also a bug that has since been resolved where the work-around was causing issues with duplicate content. This should be fixed.
I don't want to commit the code right now because it's in progress, but I wanted to poke my head in and say this thread is not dead!
Comment #7
damontgomery CreditAttribution: damontgomery commentedI have gone through all of the examples, but I haven't touched the testing file. I'll try to take a look at that.
I don't really like a lot of the examples of altering arrays and agree with the change to get rid of hook_page_alter(). That being said, to accomplish these examples, I think we need to use hook_preprocess_page() and hook_preprocess_block which does almost the same thing. I don't really like that use, but it works.
I tried to re-organize the functions in the file to be more in line with the example pages.
Please have a look and let me know. Might be worth trying to get something in as v1.0 since these patches are unwieldy.
Comment #8
jlbellidoPlease, could you attach teh interdiff? Just for simplify the review.
Thanks!
Comment #9
eojthebraveI'm going to take stab at updating this example. One question I have, before I get to deep into it. Right now the example requires the Devel module be installed. This is so that it it can use the associated
kpr()
andkint()
functions in order to display the content of various renderable arrays. Both of which print arrays in a collapsible, formatted, structure. This does make it a bit easier to read. But it then requires that Devel is installed. Are we okay with this dependency for people wanting to use the Render API example? Or should we come up with a different way of showing the information.Comment #10
eojthebraveOkay, I've been working on some Render API related tutorials for Drupalize.Me and needed some example code to go along with them. Here's my version of this so far. I haven't touched the tests yet, but everything else should be in working order. I started from the patch in #7, and then tried to add some more inline comments, and ensure things are up-to-date for both current Drupal 8 standards and best practices, as well as standards for this project.
In the process I removed a couple of examples that were basically duplication. I didn't think it was necessary to demonstrate the same thing more than once. I also added an example of adding a new RenderElement plugin,
'#type' => 'marquee'
, as this is likely to be a relatively common thing for module developers to want to do. I also made the Devel module an optional dependency instead of a hard dependency.I ran this through phpcs, and there's one violation but I believe that it's a false positive.
I anticipate the tests will fail. But wanted to share where I'm at incase someone else has time to work on the tests. Not sure I'll get around to it for at least a few weeks.
Comment #11
Mile23Thanks much, @eojthebrave
Comment #14
Mile23OK, so I re-rolled this and found a few things.
I'm pretty sure this test run will still fail...
Needs to be a BrowserTestBase test.
We should have a test without enabling devel that verifies that everything works.
I'm pretty sure these will be replaced by the web assert object from
BTB::assertSession()
.Documents itself. :-) Needs more explanation.
Comment #16
Mile23I'm working on this.
Comment #17
Mile23This patch deals with #14.1, .3, .4, .5.
The tests pass, but we still need tests for the arrays/ path and the drag and selection table parts.
The table parts should really be in fapi_example, to demo how to save the state and so forth. I can't see where they demo how to alter the form here.
Comment #18
Mile23Ewps. Forgot the patch.
Comment #19
Mile23Comment #20
eojthebraveYeah, that makes sense to me.
Thanks for working on the tests for this.
Comment #21
Mile23We don't get too far into page or render caching and we need to talk about it more, so I've made a follow-up: #2925424: Expand examples for more page/render caching use-cases I'm not sure if this info should be here or in page_example. Maybe page caching should be in page_example and render array chunk caching should be here. Decide that in the other issue. :-)
Comment #22
eojthebraveIs this @TODO still relevant? It doesn't look like 'node' is in the modules list.
I believe we can remove the
#tabledrag
stuff as that is all covered by the tabledrag_example module now.Should we also remove the
#tableselect
stuff from here before committing this? And at least open up a new issue to add that into the formapi example? And then continue that work there?Other than that the changes here look good to me. Thanks for helping to get the tests sorted out.
Comment #23
Mile23CS, properly set up config, added @todos about #prerender, etc.
Still has the tables, which we'll move eventually.
And no, that @todo is no longer relevant since the module info file says it's got a dependency on node.
Comment #25
Mile23Grr. I managed to undo the last few commits so they're not in the patch.
Comment #26
Mile23Let's try that again.
Comment #27
eojthebrave"But, if the for some reason ..." you can remove the "the" in this sentence.
I believe the syntax for this is,
$build['#pre_render'] = [static::class, 'preRender'];
Though I haven't actually tested that yet.Comment #28
Lal_@eojthebrave hope this is what you are looking for... The patch has the corrections mentioned in #27
Comment #29
eojthebraveI missed a couple of things in the previous review that I've addressed in this patch. One, is that our implementation of
'#theme' => 'item_list'
didn't work. The other, is adding back some code that was previously a part of this module which allows the demonstration page to display both the rendered, and unrendered array next to each other.At this point I would be totally comfortable with this being committed and new issues being opened for any additional bugs that come up.
Comment #30
eojthebraveOh, and here's an interdiff for #29.
Comment #32
Mile23Re-roll.
Comment #34
Mile23Fixed route paths.
Comment #36
Mile23Committed. Thanks!