How to remove default header and body fields in CCK-generated content of type Drupal?

When you create a new content type in Drupal using a content set, you automatically get the Title and Body fields in the generated form. Is there any way to remove them?

+7
drupal cck
source share
5 answers

If you are not a developer (or want to shorten the development process), another possible solution is to use the auto_nodetitle module. Auto nodetitle allows you to create rules for creating a node header. It can be program rules, replaceable tokens or just static text. Worth a look if nothing else.

+5
source share

To delete a body, edit this type, expand "Submission form settings" and place a space for the body field label. For the name, you can rename it to another text field. If you really don't need text fields, you can create your own module, for example, called foo, and create a function foo_form_alter (), which replaces $ form ['title'] #value when $ form ['type'] ['# value '] is your node type.

+3
source share

No need to install anything:
when editing the content type, click "Edit"
(in the menu "Edit | Manage fields | Display fields")
click on the form settings

on the body field label:
Leave the field blank; it will delete the Body field.

+3
source share

If you are not a developer (or want to speed up the development process), another possible solution is to use the auto_nodetitle module. Auto nodetitle allows you to create rules for creating a node name. It can be program rules, tokens that are replaced, or just static text. Worth a look, if nothing else.

And add to William OConnor solution ...

Unfortunately, the module is poorly documented. It is really effective if you use PHP with it, in my opinion. Check "Rate PHP in template" and enter in the "Template for title" field something like:

<?php echo $node->field_staff_email[0]['email']; ?> 

or

 <?php echo $node->field_staff_name[0]['value'] . '-' . gmdate('YmdHis'); ?> 

... where I have a field with the internal name "field_staff_email" and the CCK email module is used, so the type "email" was used. Or I had a field with the internal name "field_staff_name" and was just a plain text field - so the value type was used. The call to gmdate () at the end is to ensure uniqueness, because you can have two or more employees named the same.

As I discovered all this, first experimented with:

 <?php print_r($node); ?> 

... which, of course, gave crazy results, but at least I managed to analyze the output and figure out how to use the $ node object correctly.

Just note that if you use any of these PHP routines, you will get a list of contents in Drupal Admin showing the entries exactly the same as you encoded PHP. This is why I did not just use gmdate (), because then it would be difficult to find my entry for editing.

Note that you can use Base-36 to gmdate () conversion to reduce output size because gmdate ('YmdHis') is quite long.

+2
source share

The initial answers are all good. Just like another idea for the header part ... how about creating a custom template file for the cck node type. Copy node.tpl.php to node -TYPE.tpl.php, and then edit the new file and delete where the title will be displayed. (Remember to clear the cache).

Doing this means that each node still has a header, so you have no empty headers or the like for managing content.

NTN!

0
source share

All Articles