Hello,
i'm trying to use DS with Realname Module.
I want to customize the Display of the Content type "Article" and show the Author Realname (there is a field "field_realname" in Accountsettings) instead of author Username.
Normaly the Realname modul works well and it always shows the Realname, but if i add the author field in DS it only shows the Username.

I've als tried to add an "extra field" in DS with user|field_realname etc but it doesn't work. I'll be Happy if i also have the same options with this new field like "author field" this means the option "Link to profile".

Hope you can Help me :)

CommentFileSizeAuthor
#4 1344106-4.patch368 bytesswentel

Comments

Nightwalker3000’s picture

Status: Active » Closed (fixed)

I've solve this issue.
If some one need it:
Create a new "code field" in Displaysuite:
Entities =Content
Text-Format: Display Suite Code
Check the checkbox "Token"
Field Code: [node:author]
-> Click Save and you got a field with the Creator Username
Have Fun :)

castawaybcn’s picture

thanks for sharing this, it was just what I needed

szantog’s picture

Component: Field UI » Code
Category: support » bug
Priority: Normal » Minor
Status: Closed (fixed) » Active

It's still a bug. The ds_render_author_field() uses $output = check_plain($field['entity']->name);. It should be $output = format_username($field['entity']); Without format_usename the hook_username_alter() doesn't work at all.

My workaround is override the original function:

function MY_ds_fields_info_alter(&$fields) {
  if (isset($fields['author'])) {
    $fields['author']['function'] = 'MY_render_author_field';
  }
}

function MY_render_author_field($field) {
  // Users without a user name are anonymous users. These are never linked.
  $output = '';
  if (empty($field['entity']->name)) {
    $output = check_plain(variable_get('anonymous', t('Anonymous')));
  }

  if ($field['formatter'] == 'author') {
    $output = format_username($field['entity']);
  }

  if ($field['formatter'] == 'author_linked') {
    $output = theme('username', array('account' => $field['entity']));
  }

  return ds_edit_support('author', $output, $field);
}
swentel’s picture

Status: Active » Closed (fixed)
StatusFileSize
new368 bytes

You're right, committed and pushed in 7.x and 8.x