comment_driven seems to technically work with casetracker, but the normal layout of casetracker UI on comment form gets broken.
It's still useable, but the html output has changed too much (from tables and divs to divs only). It's lacking in CSS id:s, and because of that I can't correct it with CSS only. I haven't found any theme override I could use to fix it, and I can't fix it on my custom module form_alter either. See screenshots for clarification on how the output differs.
I noticed comment_driven has a module weight of 1000, which is higher than almost any other module (except for example devel). I tried setting my module weight to 1001, but it couldn't alter the form, as driven already has rendered it (it seems).
I believe running this hook or some of it (from casetracker) somewhere in comment_driven could fix it:
/**
* Implementation of hook_form_comment_form_alter().
*/
function casetracker_form_comment_form_alter(&$form, &$form_state) {
$node = isset($form['nid']['#value']) ? node_load($form['nid']['#value']) : NULL;
if (casetracker_is_case($node->type)) {
$form['#node'] = $node;
// add case options to the comment form.
casetracker_case_form_common($form);
// necessary for our casetracker_comment() callback.
$form['revision_id'] = array('#type' => 'hidden', '#value' => $node->vid);
}
}
Or maybe just running this theming function is enough? (it's defined in $form['casetracker']['#theme']).
/**
* Theme function for cleaning up the casetracker common form.
*/
function theme_casetracker_case_form_common($form) {
drupal_add_css(drupal_get_path('module', 'casetracker') .'/casetracker.css');
$output = '';
$output .= drupal_render($form['pid']);
$output .= drupal_render($form['case_title']);
if ($form['assign_to']['#type'] == 'radios') {
if ($form['assign_to']['#access']) {
$header = array_fill(0, 5, array());
$header[0] = $form['assign_to']['#title'];
$radios = array();
foreach (element_children($form['assign_to']) as $id) {
$radios[] = drupal_render($form['assign_to'][$id]);
}
$radios = array_chunk($radios, 5);
$output .= theme('table', $header, $radios, array('class' => 'casetracker-assign-to'));
}
drupal_render($form['assign_to']);
}
else {
$output .= drupal_render($form['assign_to']);
}
$row = array();
foreach (element_children($form) as $id) {
if (!in_array($id, array('pid', 'case_title', 'assign_to'))) {
$row[] = drupal_render($form[$id]);
}
}
$rows = array($row);
$output .= theme('table', array(), $rows);
$output .= drupal_render($form);
return $output;
}
See attachment for the output on my system (using the openatrium theme rubik + subtheme cube, which I've modified). I smudged some parts since they are names of real people.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 2010-04-15_proxy_pre_render_theme_post_render[unix].patch | 4.62 KB | arhak |
| #10 | 2010-04-03_support_notifications_team_and_casetracker[unix].patch | 3.42 KB | bibo |
| #9 | 2010-04-12_support_casetracker[unix].patch | 3.49 KB | arhak |
| #4 | casetracker_with_comment_driven.png | 26.91 KB | bibo |
| #4 | casetracker_without_comment_driven.png | 16.26 KB | bibo |
Comments
Comment #1
arhak commentedscreenshots?
you forgot them
Comment #2
arhak commentedthis means "don't go after cdriven unless you really know what you're doing" (e.g. sample modules attached to #760154: provide description field for driven's properties)
I left devel having weight=88, but if they got higher then probably this module should review if it is ok with that
no, it isn't rendered,
but if you're trying to reach comment_form's elements they are disguised to allow merging it with the node_form
the high weight states that we intend to be the last form_alter
regarding
casetracker_form_comment_form_alter:definitely
casetracker_case_form_commonneeds to be reviewedregarding
theme_casetracker_case_form_common:this is obviously broken by cdriven (also related to what is into
casetracker_case_form_common)I'm curious: why are you using casetracker and cdriven at the same time?
are you trying to use cdriven as a complement to some missing functionality of casetracker?
wouldn't be better to open a feature request to casetracker project?
Comment #3
arhak commentedI really appreciate your efforts to figure this out, you have been very accurate
if you want to go further I'll give you some tips
lets say that you implement (just for testing) a custom module named FIXTEST with weight=2000 (hook_enable or hook_install)
if the above code helps, then we are getting somewhere
PS: note that the above code was written in cold (I don't even have casetracker at hand at this moment) and therefore it might have some errors/typos
Comment #4
bibo commentedDang, those must have been lost on preview. Maybe this time works.
Not, that they matter much, the issue just got solved and casetrackers UI is fixed :)!
Oh, on second look its not devel-module itself that has over 1000 weight, it's one of its submodules at "/devel/performance/performance.module".
Well, actually I could have survived with casetracker alone (but the client wanted a bit more). So yes, im trying to complement
some missing features of casetracker, that is having some cck fields being editable in comments.
I'm not seeing casetracker having cck support in comments anytime soon. The idea of being able to control almost all node properties in a comment seems to have great potential.
Especially in sites driven by uhm.. comments.
Besides, it seems you're developing this module very fast and making it support all kinds of modules ;)
So, to get to what fixed the problem. I modified the "fixtest"-code you suggested a bit: changed if ($form_id != 'comment_form') { ==> $form['#id'] != 'comment-form' and the proper path to the casetracker element (and added the theme hook).
The fixtest.module looks like this now:
Result => Great success! Casetracker looks now like it was without "comment_driven".
Thanks for working with me on this (and the Wysiwyg issue).
EDIT: edited copypaste madness. I'm too tired.
Comment #5
bibo commentedChanging status to "needs review". It's pretty close to "reviewed & tested by the community" too :)
Comment #6
bibo commentedA funny sidenote: CCK support for casetracker was actually in the works with "cckasetracker" (http://drupal.org/project/cckasetracker).
It seemed rather limited, and the project page says:
.. and when you go to to "comment_cck" ( http://drupal.org/project/comment_cck ), the page says
So.. at least this project isn't being abandoned just yet ;)
Comment #7
arhak commentedgood news then
I'm thinking about a generic solution to address these element's #theme issues altogether
(i.e. this issue and #761288: Compatibility with Team Notifications but both with a different unified approach)
PS: for other users reading this issue, the code posted above is ONLY for testing purposes, the fix for this issue won't require another module
Comment #8
arhak commented@bibo: thank you so much for your tests & feedback
Comment #9
arhak commentedattached patch should fix this
it follows the proxied #theme approach
(without needing the custom module)
to test it:
- remember to disable any version of the FIXTEST module
- clear the cache (a new theme function is being declared by comment_driven)
PS: right now I have no time to test it myself
this patch should address #761288: Compatibility with Team Notifications in passing by
Comment #10
bibo commentedTook me a while to start testing this patch (I'm supposed to do my thesis which is due soon :p).
It didn't seem to work: both casetracker and team_notifications UI:s were messed up.
I started fiddling around and found the reason:
$element['#theme_used'] = true;. That is, Drupal thinks the form element theming is now handled and we're done with it, so it won't get themed after the undisguising. Or that's how I understand it. I tried setting that var to "false".. and both notifications_team and casetracker got rendered fine. Yay :). Probably would fix lots of other modules' output too?Again, I only added this "$element['#theme_used'] = false;" to the theming function, which looks now like:
Please try the attached patch (for alpha-2).
Comment #11
arhak commented@10 lots of kudos for you bibo!
absolutely right
the new proposed approach is delegating to drupal_render, therefore it makes sense to clear that flag
since we are not directly invoking the theme function (which was the first test's approach)
indeed
it is a critical missing piece of this puzzle
thanks
Comment #12
arhak commented#10 seems great to me, but we are only addressing $element['#theme']
what about $element['#pre_render'] & $element['#post_render'] ?
- if $element['#theme'] is defined they will be also handled by drupal_render
- but otherwise they will continue malfunctioning (i.e. broken)
- besides, using drupal_render looks straightforward, but it is being processed twice
the new proposed patch (which I haven't tested not even once, yet)
attempts to address not only #theme, but also #pre_render & #post_render
since right now we don't have any contrib module using pre_render/post_render without #theme (which might be a rare case to find)
I would like to have bibo's opinion on this (code review)
I know this time the code doesn't look as simple as before
but it is addressing three different render's fragments with the same approach
for users not involved in code review, this patch is intended to behave the same as #10
Comment #13
bibo commentedPatch in #12 works great for me! casetracker and team_notifications UI seem normal.
Currently I can't do further testing, I really have to concentrate on my thesis for a while. Luckily it's about Drupal ;)
I'm glad this is fixed and I could be of help :).
Comment #14
arhak commented@#13 thanks, and good luck!
Comment #15
arhak commentedcommited to HEAD
remember that this requires to clear cache
(there is a new theme function)