I would like to change the "Summary" title of the "Body" field element to "Excerpt" while you are editing a node. Can anyone tell me how to do that? Is it in the field.tpl.php? or somewhere else.

Comments

thomaske’s picture

What type of node are you trying to change?

For an article, you could go to Structure>Content Types>Article>Manage Fields>Body

And you could change the visible name.

tk

cabplan’s picture

So I understand I can open up the Body field of my "Website Page" content type but there is nowhere to edit the label called "Summary". When you click on "Edit Summary" it shows the Summary box but how do I change the "Summary" label to something else?

thomaske’s picture

you should see a pane called "label" that enables you to change the name.

[URL=http://s519.photobucket.com/user/unokubizukuri/media/bodyfield.jpg.html]...

cabplan’s picture

I do see the "Label" field but that is for the main Body field not the Summary field that is associated with the "Text area with a summary" widget type. That widget gives the ability to click on the "Show Summary" which it then has a label saying "Summary". I think I can change this with a hook_form_alter but I have no idea how to target that element. Can anyone help me write a hook_form_alter that targets the Summary label?

millionleaves’s picture

I found this page when trying to do the same. I also found the solution in this question in an answer to a similar but different question here:

http://drupal.stackexchange.com/questions/5624/renaming-the-label-of-the...

You need to to add a new function to your template.php file, which is found in your theme, and adjust it according to your requirements:

function themename_preprocess_field(&$variables, $hook) { 

    if($element['#field_name'] == 'field_xyz') {
      $variables['label'] = "your label name";
    } 
}

I provide Drupal, Drupal Commerce and CiviCRM development services for customers in New Zealand and beyond

vramiguez’s picture

I think that what you're looking for is the following solution:

function hook_form_alter(&$form, &$form_state, $form_id){
      $form['body'][LANGUAGE_NONE][0]['summary']['#title']='New label';
}

If you want to change the label according to the form, you can use the $form_id.
This will change the label in your edit form. However, it will keep the (Hide Summary) link.

I know it was asked long time ago, but perhaps can help someone else.