I've searched the drupal.org up and down and up to page 15 on Google, can anyone enlighten me as to how I can remove the suffixed colon at the end of a field's label?

This is purely for aesthetic purposes

Thanks in advance

Comments

swentel’s picture

Status: Active » Closed (fixed)

The easiest way is this:
Override the theme_field function in your template.php if you like and remove that colon in there. See http://api.drupal.org/api/drupal/modules--field--field.module/function/t....

elgandoz’s picture

Version: 7.x-1.x-dev » 7.x-1.2
Component: Code » Field UI
Category: support » feature
Priority: Normal » Major
Status: Closed (fixed) » Active

I used this in my template.php

function mytheme_field($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':&nbsp;++</div>'; //<-- HERE the colon
  }

  // Render the items.
  $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
  }
  $output .= '</div>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';

  return $output;
}

Where i tried to put some ++ after:&nbsp; , But this is not working. My label has to be a word without colon before the value.
It would be nice have this option directly in Display Suite UI.
Any helps?

elgandoz’s picture

PS: using that also appears...

Notice: Undefined index: scale in number_field_formatter_settings_summary() (linea 264 di [...]\drupal\modules\field\modules\number\number.module).
Notice: Undefined index: decimal_separator in number_field_formatter_settings_summary() (linea 264 di [...]\drupal\modules\field\modules\number\number.module).
Notice: Undefined index: thousand_separator in number_field_formatter_settings_summary() (linea 264 di [...]\drupal\modules\field\modules\number\number.module).
Notice: Undefined index: prefix_suffix in number_field_formatter_settings_summary() (linea 265 di [...]\drupal\modules\field\modules\number\number.module).

Tony Finlay’s picture

Status: Closed (won't fix) » Active

function (1 - Replace This)_field($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':&nbsp;</div>'; //<-- Here's the colon to delete, it's attached to a space (&nbsp;)
  }

  // Render the items.
  $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
  }
  $output .= '</div>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';

  return $output;
}

What you have to do is replace (1^) with the name of your theme, then delete the colon above pointed out by the comments.

Finally just paste this code into a template.php file and save it in your theme folder, then clear your cache (under: configuration > performance) click on the appearance tab, refresh the page and save the configuration, when you go back the colons should be removed.

swentel’s picture

Status: Active » Closed (won't fix)

Post in #4 is correct. #3 are errors not related to DS, and I'm not going to make this an option for now. There are easy overrides possible for this problem.

swentel’s picture

Status: Active » Fixed

Note, in the next release, there will be an option to remove the colon completely for the reset function or there is an option with the 'expert' field template to remove it as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

zhuber’s picture

You can use this if you want as well.
Paste this block into your version of 'page.tpl.php' in your template folder.

    drupal_add_js(
      'jQuery(document).ready(function () {
        var labels = jQuery(".field-label");
        jQuery.each(labels, function() {
          this.innerHTML = this.innerHTML.replace(":", "");
        });
      });',
      'inline');
  
Jessica A’s picture

#4 works, thanks!!

jacquelynfisher’s picture

#8 worked for me. #4 did not.

liza’s picture

that jquery is amazing. thanks!