I spent a few hours figuring this out so am posting this in the hope it helps others...
I needed to position the feedback block inside my node content. No problem I thought, just add to code to insert the block where you want it to show up in node.tpl.php (same code actually used in feedback.module to insert in footer)
if (user_access('access feedback form')) {
$feedback_block = (object)module_invoke('feedback', 'block', 'view', 'form');
$feedback_block->module = 'feedback';
$feedback_block->delta = 'form';
return theme('block', $feedback_block);
}
}
It shows up on the page... so was very proud of myself until I tried to submit the feedback and although it was actually submitted (showing up in the feedback report), the widget did not collapse to show the "Thanks" message! It just hung there....
Well, I am sure this is obvious to some, but the reason is that if you call the module_invoke when some html has already been outputted from node.tpl.php then the html shows up in the server response (in addition to the properly json formatted thanks message), hence the response is then invalid json and therefore does not trigger the function that collapses the widget.
So the solution is:
1. Call module_invoke AT THE VERY TOP of node.tpl.php
if (user_access('access feedback form')) {
$feedback_block = (object)module_invoke('feedback', 'block', 'view', 'form');
$feedback_block->module = 'feedback';
$feedback_block->delta = 'form';
}
2. Call the print theme inside node.tpl.php where you want the form to actually show up
if ($feedback_block) {
print theme('block', $feedback_block);
}
Comments