Drupal how to render seperate fieldgroups from a content type (and a display suite trick)

Posted by: 
Dominique De Cooman

A cck fieldgroup can be rendered alone. We had some quicktabs we wanted to fill with our field groups. So we've builded a block for each field group to put in the quicktabs. Here is an example of one block where we called a single fieldgroup and rendered it.

First you call all fieldgroups information for a certain content type and then you give the fieldgroup_view_group function the correct fieldgroup definition and your node.

<?php
/**
 * Implementation of hook_block()
 */ 
function glue_block($op 'list'$delta 0$edit = array()) {
  if (
$op == 'list') {
    
$blocks[0] = array(    
      
'info' => t('Company Info'),
    );
    
    return 
$blocks;
  }
  else if (
$op == 'view') {      
    switch(
$delta) {
      case 
0:            
        
$node menu_get_object();
        if (
$node->nid) {
          
$groups fieldgroup_groups('company');
          
          
$node->build_mode 'groupcalls';
          
$content fieldgroup_view_group($groups['group_vennootschapinfo'], $node);
  
          
$block = array(
            
'subject' => t('Company Vennootschaps info'),
            
'content' => $content,
          );   
        }
        break;
    }
    return 
$block;
  }
?>

As an extra if you want to control the fieldgroup field order, but you dont want to mess with the order of your teaser or full node. When using display suite you can make a custom buildmode (for example groupcalls) and in that buildmode you determine the order of your fieldgroups.

Add new comment