2

I created a custom content type with some text fields. In the view settings of that content type I defined both to appear and as well their titles (names of the fields) to be displayed above the content of the fields respectively.

But how can I remove the trailing colon of the titles? Is there a way of modifying the way field names are display just for certain content types? I do not want this altered site wide (e.g. for all fields of all content types).

PS: I'm already using the "views" module to define a special layout for this custom content type. Probably there is a way to carry out these changes with the help of the "views" module and a custom layout template?

/edit/
I did not create a view (as with the "views" module) to display that content but used Drupal's own content type view configuration (maybe called "display"). I'm working with a localized Drupal and retranslating the different words.

Remark: Using Drupal 7.10 with Views 7.x-3.0-rc3

8

Note: The OP is not talking about Views. (In Views you can uncheck a box that says Place a colon after the label).

The accepted Drupal method is by copying the core field.tpl.php file into your theme directory and manually removing the colon from the file.

modules/field/theme/field.tpl.php
sites/all/themes/[mytheme]/field.tpl.php

In Drupal 7 this is on line 55:

from:

<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>

to:

<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>&nbsp;</div>

In order to do this in a specific content type you first copy field.tpl.php to your theme, then duplicate it, adding the machine name of your content type, and remove the colon from the content type specific version.

sites/all/themes/[mytheme]/field.tpl.php
sites/all/themes/[mytheme]/field--[content-type].tpl.php

Note: the double hyphen (--) is not a typ-oh.

Read up on theme suggestions for more. Using suggestions you can target just a specific field in this content type, just the field globally, all fields in the content type, or all fields in all content types. Or handle every combination differently.

4

For Drupal 7 you can use the Display Suite module. After you installed this, you can enable the Display Suite Extras. Now you can set for each field "expert" values. So you can for example remove the default wrappers and classes for each field, or rename the field to something else or you also can choose to remove the ":". Very handy. If you need to know more, i can give you a more detailed explanation on how to achieve this.

2

I know this is a super old question, but nowadays there's also the Colonectomy module.

This simple module allows the colon punctuation mark to be removed from field labels.

  • Ugh - what a muppet. I've just realised there's no full release for that module. I'll leave it here anyway for posterity's sake. – Chapabu Aug 20 '13 at 10:38
  • There's the Colectomy module, though. ^^ drupal.org/project/colectomy – s427 Jan 19 '15 at 11:00
0

Maybe you would like to check https://drupal.stackexchange.com/a/17770/53 . It's related with linked titles, but the issue with the colon can be corrected using the same module.

0

I normally use javascript to remove colons from webforms, you may be able to do the same for a node page, just by choosing a different selector.

eg.

$('.webform-component label').each(function() {
  var text = $(this).html();
  $(this).html( text.replace(':', '') );
});  
0

In Drupal 6 at least, you would first copy CCK's field template, content-field.tpl.php, from its theme directory into your theme, and then copy it to the specific field name you want to theme, eg, content-field-FIELDNAME.tpl.php, then edit out the hardcoded :, flush caches and see what's what. Something similar will most probably work for D7. For the exact details, check out http://api.drupal.org/api/drupal/modules--field--field.module/function/theme_field/7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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