You are here

function fieldgroup_panels_render_fieldgroup in Content Construction Kit (CCK) 5

'Render' callback for the 'fieldgroup' panel.

1 string reference to 'fieldgroup_panels_render_fieldgroup'
fieldgroup_panels_content_types in ./fieldgroup.module
Implementation of hook_panels_content_types()

File

./fieldgroup.module, line 568
Create field groups for CCK fields.

Code

function fieldgroup_panels_render_fieldgroup($conf, $panel_args, $context) {
  $node = isset($context->data) ? drupal_clone($context->data) : NULL;
  $block = new stdClass();
  $block->module = 'fieldgroup';
  if ($node) {

    // Assemble the fields into groups
    $node = node_build_content($node);

    // Get the "machine name" of the group from the options
    $groupname = $conf['group'];

    // Print out the contents of the given group
    // Note, not using drupal_render($node->content[$groupname]) here to avoid printing the fieldset
    $vars = array();
    if (is_array($node->content[$groupname])) {
      foreach (element_children($node->content[$groupname]) as $key) {
        $vars[$key] = drupal_render($node->content[$groupname][$key]);
      }
    }
    $block->subject = $node->content[$groupname]['#title'];
    $block->content = $vars ? theme('fieldgroup_panel', $vars, $node->nid) : $conf['empty'];
    $block->delta = $node->nid;
  }
  else {
    $block->subject = $conf['group'];
    $block->content = t('Content fieldgroup content goes here.');
    $block->delta = 'unknown';
  }
  return $block;
}