deepakjoshi
deepakjoshi

Reputation: 19

What are the benefits of reusing an existing CCK field for a content type?

What are the benefits of reusing an existing field for a content type?

Alternatively, what are the benefits of making a new field for a new content type?

For example, I have a content type called 'Book Review' with a field labeled 'Summary'. I'd like to create a new content type called 'Movie Review' and also give it a field called 'Summary'.

Upvotes: 1

Views: 435

Answers (2)

Gokul N K
Gokul N K

Reputation: 2458

Benefits of reusing an existing field

  1. One table(in fact 2) less in your database and hence the performance gets better.
  2. Say when you want to display the summaries of all the content(irrespective of content type), reusing the existing fields will make your queries simpler.
  3. When you are using views for the displays you just need to add one fields instead of different fields for each content type. Say you want to display summaries of both Book Review and Movie Review, you can just add both to the content type filters(or) and add the single common field.
  4. When you are overriding the template files, you just need to overwrite one template instead of many.

Benefits of using different(new) fields

  1. If both the fields has to be displayed separately, then you can have more control.
  2. If there are very large number of values in your fields, then instead of querying a single table with 1 lakh entries, you will only need to query a table with 50,000 entries. This might add to your performance(But am not very sure, can be case specific)

My preferred choice

  1. Reuse existing fields when it makes functional sense. For example I generally reuse noderefernces to the parent content type so that it keeps most of my queries simple.
  2. In your user-stories if it doesn't make sense to reuse then better go for the the new fields.

Upvotes: 1

Adi
Adi

Reputation: 1273

Reusing same field - Let you handle the field at one place. Code handling + theming. Making a new field - summery is not a good example, since you have a built in text area given by Drupal. Adding an image field with the same preset size for both (movie & book) will give you the ability to show images on each content type and let them look the same if you want (without double work).

Upvotes: 0

Related Questions