2

So I'm using display suite with a 2-column layout, and my node has an entity reference field (field_journal). I'm already displaying field_journal as a rendered entity in the LH column, but I'd also like to display a different grouping of fields from the linked entity in the RH column.

I was thinking the best way to do that would be to add field_journal again to the RH column, but I can't figure out how to duplicate fields in display suite.

Is there some way to add the same field to a node display in 2 different places in the layout? Or can anyone help me with a workaround?

1 Answer 1

0

Since you're using display suite you can use hook_ds_fields_info for defining a new display suite field that you can use to clone your existing field.

/**
 * Implements hook_ds_fields_info().
 */
function MODULE_ds_fields_info($entity_type) {
  $fields = array();

  $fields['node']['journal_clone'] = array(
    'title' => t('Journal clone'),
    'field_type' => DS_FIELD_TYPE_FUNCTION,
    'function' => 'MODULE_journal_clone',
  );

  if (isset($fields[$entity_type])) {
    return array($entity_type => $fields[$entity_type]);
  }
  return;      
}

/**
 * Render a clone of journal.
 */
function MODULE_journal_clone($field) {
  $build = '';
  if (isset($field['build']['field_journal'])) {
    $build = $field['build']['field_journal'];
  }
  return render($build);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.