Hello,
For some special needs (allow DND everywhere over Drupal) I needed to interract with the composite module quite deeply. I was suprised to see that there is no hooks at all that allow other modules to interract over zone rendering, so I did a quite big, but comprehensive patch that creates a simple zone template, and allows other module to act via the hook_preprocess_template().
Other ideas in this patch are:
- Get a more comprehensive hook_nodeapi() implementation by encapsulating the code in comprehensive functions
- Move theme related code to their own file, indeed, you .module files begins to be really huge, and move some parts of the code in files handled by the theme registry will highly help your code to be maintenable
I think there is some more progress to do in this way, your methdos that build up the references and store them into the node object are not really easy to understand, and the custom layout templates have data redundency in their signatures, but changing this would mean an API change.
Right now, my patch keeps the API compatibility and won't break custom modules using it.
For testing purposes, this patch also includes the #775456: Recursion detection on render (avoids WSOD). patch, and should patch on the vanilla 6.x-1.0-beta8 version.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | composite-817302-patch.txt | 35.71 KB | bengtan |
| #12 | composite-6.x-1.0-beta8-theme-better-4.patch | 23.67 KB | pounard |
| #10 | composite-6.x-1.0-beta8-theme-better-3.patch | 22.21 KB | pounard |
| #7 | composite-6.x-1.0-beta8-theme-better-2.patch | 12.29 KB | pounard |
| #6 | composite-6.x-1.0-beta8-theme-better.patch | 12.08 KB | pounard |
Comments
Comment #1
pounardComment #2
pounardAnother thing that would be really cool (for design, and for other modules) is that your theming functions overlapping could implement the decorator pattern, this would implies that the layout rendering triggers each zone rendering, which themselves triggers each reference rendering.
By cascading theming functions this fashion, modules would be able to "mark" some layout being rendering and access layout and node information during the full process, keeping the context in which each element is being rendering.
This information might not be usefull for you, but would be for a lot of modules and even themes themselves.
In my case, I need it, and something is wrong with your actual way of rendering things for me, is that those context information is really missing, and references are being redered before zones, which actually breaks my container/items introspection in order to put the right classes and stuff for js composite zones and references detection.
EDIT: I'm currently working on it, patching the full rendering algorithm in order to reduce some arrays iterations, passing some of them as references instead of array recopy (even if PHP does some optimizations arround it, they are actually not always accurate). I'll also implement the decorator pattern in the theme process. The only difficulty here is to keep it backward compatible.
RE-EDIT: You are also currently using the drupal_render() function with its facilities such as children_element() and such. In most case this could be avoided by taking a more pragmatic approach without wiping out totally the current design.
Comment #3
bengtan commentedIssue noted. I need to look into this deeper.
Comment #4
pounardOk, thanks in advance for your time. I have some to spare for your module, please use it:)
Comment #5
pounardThis patch is more like a proof of concept than real clean code. In fact I'm trying to rewrite this piece of code and don't find a clean solution to do whatever I need to do. Still trying to find a clean pattern.
Comment #6
pounardAnd here is another (which I think is better) patch. Did this because I needed it. It might need some more work, but it works as expected in my environment.
Comment #7
pounardLast one, this is one is better, I cleaned up theme functions signatures to ensure that no useless arguments are passed, this also simplify a bit their usage.
It uses an algorithm which looks like the decorator pattern, each layer of rendering is responsible for running the lower ones, and it works pretty flawlessly.
I'm currently using it in the DND module I'm working on.
Comment #8
bengtan commentedHi,
Looking at the patch in comment #7 ... whilst I haven't executed it on a running site, it does look fairly clean. You've moved some code around and added a bunch of theme hooks without changing any existing functionality. I'm fairly happy with it.
So the question is ... is this the 'final' version of your patch that I should consider for submission? Or are you still making changes (in order to have it do fancy things on your site)?
Comment #9
pounardActually I may have some modifications to do. And because I'm the only one using it, I also think it really needs more testing! Unit tests should be done to ensure it works properly.
Comment #10
pounardHi, here is a new patch. I did some really basic unit testing using simpletests, it far from being complete, but that's a start. Doing these tests I was able to spot *a lot* of PHP warning on non setted variables, that I fixed all among your code.
Here is the complete patch, including:
Have fun testing & reviewing (this should not be that hard).
Comment #11
pounardNote: IMHO, this patch is ready for me (at least for beta releasing). Still convince that it needs some community testing since I have a really specific use case of your module.
Comment #12
pounardStill doing some progress on the patch. I added a variable so the site admin can choose weither or not composite should display the recursion error when detected. I added this as a checkbox in a new administration page under admin/settings/composite.
Everything else is exactly the same as the forth (-3, last one) patch I submitted.
Comment #13
bengtan commentedHi,
I've tried your patch from comment #12 and made some changes.
I had to move some files and functions around. Aside from that, there were a few minor bugs and stylistic differences, but nothing else major.
(Whilst working on this, I discovered that when I move .tpl.php files around, Drupal would still pick up the file from the old location even though the file isn't at that location in the filesystem anymore. Turns out APC was caching .tpl.php files even after the files were made non-existent. If you also have APC (or some other opcode cache) enabled on your system, you might want to turn it off before testing.)
Please give it a quick try and if nothing obviously breaks, then hopefully it will be ready to commit.
Comment #14
pounardSorry, I did not answer for a long time, I will test it as soon as I can, expect an answer for the next days.
Comment #15
pounardHi, I did not answer for a long time (bis). I'm actualy testing your patche right NOW! :)
Comment #16
pounard@bengtan
I'm currently using your patch, and since the last 10 minutes (did some functional tests arround) it seems to be working fine.
I'm convinced that it needs further testing, but until now, this patch is OK for me.
Comment #17
bengtan commentedCommitted (http://drupal.org/cvs?commit=394180).
Thank you.
Comment #18
pounardOk, nice! I'm still convinced it needs further testing (at least all possible CRUD tests using simpletests) before it gets released. I'll see if I have some time to do it.