Posted by HJulien on August 5, 2015 at 7:57pm
In Drupal 6 I had it working where a OG group admin (worked in non-groups as well) could post a question above the shoutbox.
This is the set up:
- I added a field in the content type of the group. Mine is called field_speak_up_topic. Admins could change the question as often as they liked.
-
Then a Drupal block was created with the code below:
<?php
$node = menu_get_object();
$block = module_invoke('shoutbox', 'block', 'view', '0');
print '<div id="speakup_question">'. $node->field_speak_up_topic[0]['value'] .'</div>';
print '<div id="speakup_box">'. $block['content'] .'</div>';
?> - Then the block was placed in the panel node of the group or page.
This worked great until I upgraded to Drupal 7. Now it doesn't work. The menu_get_object is still in the D7 API. Maybe the module_invoke changed or the way to get the field content into $block?
Don't know why. Any ideas?
Comments
Help to change D6 code to D7 code
module_invoke call has been changed in Drupal 7, in 2nd line change the module_invoke call with following code-
$block = module_invoke('shoutbox', 'block_view', '0');
Thanks for the tip but it's
Thanks for the tip but it's still not working. Maybe something else is also wrong?
Thanks for the tip but it's
Thanks for the tip but it's still not working. Maybe something else is also wrong?
Thanks for the tip but it's
Thanks for the tip but it's still not working. Maybe something else is also wrong?
Thanks for the tip but it's
Thanks for the tip but it's still not working. Maybe something else is also wrong?
Need to change last line also
You also need to change the last line-
print '
'. $block['content'] .'
';
to print '
'. $block['content']['#content'] .'
'; or you can use print '
'. render($block['content']['#content']) .'
';
If those don't work try to dump $block using print_r($block) or dpm($block) (you must have devel module installed for that) and use the correct value to print.