Help to change D6 code to D7 code

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
HJulien's picture

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:

  1. 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.
  2. 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>';
    ?>
  3. 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

Sarwar Zahan's picture

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

HJulien's picture

Thanks for the tip but it's still not working. Maybe something else is also wrong?

Thanks for the tip but it's

HJulien's picture

Thanks for the tip but it's still not working. Maybe something else is also wrong?

Thanks for the tip but it's

HJulien's picture

Thanks for the tip but it's still not working. Maybe something else is also wrong?

Thanks for the tip but it's

HJulien's picture

Thanks for the tip but it's still not working. Maybe something else is also wrong?

Need to change last line also

Sarwar Zahan's picture

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.

Toronto

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week