Changing body field to text input, not textarea

Events happening in the community are now at Drupal community events on www.drupal.org.
newz2000's picture

Is there a way to make the body field of a content type into an instead of a ?

Comments

CCK?

scottatdrake's picture

I'd just hide/disable the body and use a CCK field instead. Is there a reason that wouldn't work?

How do you hide the body?

newz2000's picture

I've never seen a way to hide the body field. Is this something you can do through the UI?

--
Matthew Nuzum
newz2000 on freenode

Yep

scottatdrake's picture

Go to admin/content/types and edit your content type. Look under Submission form settings and Body Field Label. It says:

"To omit the body field for this content type, remove any text and leave this field blank."

Oh, awesome! thanks, I've

newz2000's picture

Oh, awesome! thanks, I've used that form countless times and not noticed that.

--
Matthew Nuzum
newz2000 on freenode

is there a way to transfer the old bodies into the new CCK

qriz's picture

is there a way to transfer the old bodies into a new cck field? And if possible multiple value text field (a new value per line)???

No and yes

scottatdrake's picture

I don't know how to transfer the text off the top of my head. You could possibly export them and import them again, mapping the body to the new cck field. There are a few modules that could possibly help in this article. Putting each line into a separate field would be tricky.

You can create multiple value text fields by editing your content type, then manage fields, then configure the field you want, then select "unlimited" under number of values.

Thx 4 the quick reply

qriz's picture

I have around 1200 nodes, half of them have old notes (written into the body) before I decided to create a new CCK Field with multiple values to have the notes separated for reuse in views and panels for better positioning.

Now I need to transfer just the body field values and then turn them off by emptying the body title, because I use the rest of the node to display in a small panel region what gets messed up by the old notes.

I thought it could be done with a db query like this

INSERT INTO content_field_newnotes( vid, nid, field_newnotes_value )
SELECT vid, nid, body
FROM node_revisions
WHERE type='stormorganization'

but something is not right formulated

I got at least the basic version working

qriz's picture

INSERT INTO content_field_newnotes( vid, nid, field_newnotes_value )
SELECT vid, nid, body
FROM node_revisions

worked after I emptied that table.

Now it would be awesome if somebody could help me to formulate a version to that one line one value problem

Migrate body field to CCK text field

SeanA's picture

I needed to move the contents of the body field into a cck text field, and figured out some SQL to make this happen. Here it is, in case it's useful to someone. First I created a new text field on my content type, then did:

UPDATE content_type_yourcontenttype
SET field_yourtextfield_value = ( SELECT node_revisions.body
FROM node_revisions
WHERE node_revisions.nid = content_type_yourcontenttype.nid )
WHERE EXISTS ( SELECT node_revisions.body
FROM node_revisions
WHERE node_revisions.nid = content_type_yourcontenttype.nid );

If you're doing this kind of stuff of course you don't need to be reminded to back up your database first!

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: