I have a node type called 'basic' with 10 nodes and a bunch of fields. However, I want to add a field that is specific to only one node. What is the best way to do that?

At the moment I've got a custom field and I'm hiding it using hook_form_alter() ['#access'] = FALSE (and hiding visibility via the UI), so it's not editable or visible for the other 9 nodes, which works but I'm worried this isn't the best way performance wise. Aren't those field tables then being joined for every node call?

Using the Form API isn't an option because I want to take advantage of the field widgets (using unlimited values etc).

Any ideas?

1 Answer 1


Dealing with such a limited number of nodes, my first reaction would be to clone the content type, say 'basic_extra', and add the field to the clone. Just make sure to change the scope of any views including 'basic' to include both. It would eliminate a lot of work for only one node.

  • Thanks for the reply. I should have mentioned in this case the values will increase in future. I expect 5+ different nodes to require fields that are specific to that node. Do you know if there is a hook available so I can tell node_load not to join fields in the query? Mar 31, 2013 at 19:41
  • The performance hit for joining one field will be minimal. If you were talking about 500+ nodes with unique fields ... but if the number is manageable (5+) I stand by my original response, whether each node has its own unique field, or all 5+ nodes use the same extra field. Even if there is a hook, you are still going to have to tell the function which fields not to join, which will be an extra database action. The easiest and most performance efficient is to define the node type with the fields you want, then let drupal handle the rest.
    – Triskelion
    Mar 31, 2013 at 20:15
  • It's actually a field collection, so technically it's a hand full of fields for that specific node. I like your idea, but it may confuse the administrator when filtering node types in the main content page. I think perhaps I'm being too careful. The node type has 10 fields, and another 5 more that are unique to a single node, so I guess it's okay just to hide those 5 fields via hook_node_alter()? Do fields get cached per node, if so then I guess it's not a problem? Mar 31, 2013 at 20:33
  • Okay, so it looks like Drupal does cache fields individually for each node. So it's not as bad as I thought it would be. I was worried after the page cache was cleared there would be a query with lots of joins for each page, but if the field cache is there then it's not so bad at all? Mar 31, 2013 at 20:41
  • Anyone with access to the main content page should have basic knowledge of the site architecture. Involve the administrator in the decision.
    – Triskelion
    Mar 31, 2013 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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