Thursday, April 1, 2010

Hide custom CCK feild in a node and make it visible in view

Drupal Tip CCK Hide Node Show View
Drupal Tip: Hide CCK Field on Node, but Display in View
I had a need to do something on our Drupal site today and couldn't find the answer on the web, so I thought that I'd post the solution I found. I suppose it is so simple, it wasn't on the forums, but it seems like many people have asked this question before and been led down many paths.

Scenario: How do I display a CCK field in a View, but hide the field on the actual node?
Seems simple right? Well, if you look on the web, most answers tell you to use permissions to hide the field. That won't work, because you want to display it in one place for a user in not display somewhere else, for the same user.

I'm fairly new to Drupal, so I presume that this was difficult at one point, given the solutions I found when people asked this question running Drupal 5.x. However, it is fairly easy now in Drupal 6.

Solution: Set the field to "hidden" for Node and "default" for the teaser
1. In the Administration Menu, go to Edit Content Type > Select your Content Type.

2. Then go to Display Fields

3. Next to the field you are working with, under Full Node, set the drop down box to "Hidden"

See Image:

And there you go. Now the CCK field will be available in your views and panels, but will not show up in your Node. And all without permissions, computable fields, or any complicated logic.

Drupal Tip Summary
Sometimes you might want to create a field using CCK, and use the field for a view. However, you might also need this field to not show on your node, so you need to "hide" it on the node while leaving it accessible for all other uses.

If you have any questions or would like to see a specific issue discussed, let us know by posting a comment or by contacting us.

No comments:

Post a Comment