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.

Comments

pounard’s picture

Status: Active » Needs review
pounard’s picture

Another 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.

bengtan’s picture

Issue noted. I need to look into this deeper.

pounard’s picture

Ok, thanks in advance for your time. I have some to spare for your module, please use it:)

pounard’s picture

This 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.

pounard’s picture

StatusFileSize
new12.08 KB

And 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.

pounard’s picture

Last 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.

bengtan’s picture

Hi,

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)?

pounard’s picture

Actually 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.

pounard’s picture

Hi, 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:

  • The exact same patch as upper, plus:
  • The basic unit testing code;
  • isset() and empty() more tests, all among the code to avoid PHP warnings;
  • simple patch (add a foo region on blocks) in block module integration to avoid core block rendering function from outputing PHP warnings;
  • Some caching using cache_get() and cache_set() in order to achieve better performances on some parts of the code.

Have fun testing & reviewing (this should not be that hard).

pounard’s picture

Note: 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.

pounard’s picture

Still 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.

bengtan’s picture

StatusFileSize
new35.71 KB

Hi,

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.

pounard’s picture

Sorry, I did not answer for a long time, I will test it as soon as I can, expect an answer for the next days.

pounard’s picture

Hi, I did not answer for a long time (bis). I'm actualy testing your patche right NOW! :)

pounard’s picture

@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.

bengtan’s picture

Status: Needs review » Fixed

Committed (http://drupal.org/cvs?commit=394180).

Thank you.

pounard’s picture

Ok, 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.