I'm classifying this as a feature request since this may be the desired behavior for Display Suite. This documentaton node explains how to add HTML to a node title by adding code to the template. However, I have commented the title out of my theme so that I can better customize it through Display Suite. I recognize why it would be undesirable on some sites to have an option for HTML in the title field, but this site will be personal and I'd really like to utilize as much flexibility as possible.

Is it possible to add code to a part of the Display Suite module to accomplish this?

Comments

Barry Tielkes’s picture

I'm having the same problem. I need abbr tags in my titles.

gollyg’s picture

DS defines a rendering function for the node title, so one approach is to override this rendering function using hook_ds_field_info_alter(). This allows you to override the default rendering function (ds_render_field) and replace it with your own.

In a bit more detail at http://thislittleduck.com/content/display-suite-and-html-node-titles.

swentel’s picture

Status: Active » Closed (works as designed)

Yeah, while I understand the use case, it's relatively rare. There are hooks and and now also articles like in #2 explaining how to circumvent this.

Anonymous’s picture

Solution in #2 worked for me. Saved me a bunch of time. Thank you!

jgullstr’s picture

Issue summary: View changes

Link in #2 is dead.

For future reference, here's an example of a conditional override:

/**
 * Implements hook_ds_fields_info_alter().
 */
function MYMODULE_ds_fields_info_alter(&$fields, $entity_type) {
  if ($entity_type == 'node') {
    $fields['submitted_by']['function'] = 'MYMODULE_render_submitted_by';
    $fields['submitted_by']['module'] = 'MYMODULE';
  }
}

/**
 * Custom "submitted by" callback.
 */
function MYMODULE_render_submitted_by($field) {
  $node = $field['entity'];
  $view_mode = $field['view_mode'];

  if ($node->type == 'MY_CONTENT_TYPE' && $view_mode == 'teaser') {
    $account = user_load($node->uid);
    $date_format = str_replace('ds_post_date_', '', $field['formatter']);
    return t('!date | !user', array('!user' => theme('username', array('account' => $account)), '!date' => format_date($node->created, $date_format)));
  }
  // Fallback to default.
  $field['module'] = 'ds';
  return ds_render_submitted_by($field);
}

I have no idea if the 'module' key is used anywhere, but keeping it up to date should make for easier debugging.

jieyyal’s picture

Here is a more specific reference:

https://www.drupal.org/node/2391803