Dominique De Cooman
Published on Dominique De Cooman (https://dominiquedecooman.com)

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

Dominique De Cooman
Wednesday, June 23, 2010 - 22:21
cck [1]
fields [2]

A cck fieldgroup can be rendered alone. We had some quicktabs [3] 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 [4] you can make a custom buildmode (for example groupcalls) and in that buildmode you determine the order of your fieldgroups.


Source URL: https://dominiquedecooman.com/blog/drupal-how-render-seperate-fieldgroups-content-type-and-display-suite-trick

Links
[1] https://dominiquedecooman.com/blog-topics/cck
[2] https://dominiquedecooman.com/blog-topics/fields-0
[3] http://drupal.org/project/quicktabs
[4] http://drupal.org/project/ds