0

I have a content type that has several CCK fields: date, session number, session type, sold out, and homepage eligibility. The values of the fields are in no way stored in the body of the node as far as the database is concerned; here's the contents of the body field from one node in the node_revisions table:

<p>The word &ldquo;insight&rdquo; is one of the most misunderstood and misused words in the marketing world today, but it is also one of the most important. As consumers become more fragmented and individualized, they will increasingly look for brands that represent some aspect of who they are. Brands will have to understand their target from an insights perspective. It will no longer be sufficient to settle for target generalizations.</p>
<p>In this seminar participants will take his/her knowledge and application of insights to an entirely new level. This seminar will teach attendees how to:</p>
<ul>
  <li>Identify real insights and distinguish them from generalizations, significantly improving the quality of an organization&rsquo;s insights.</li>
  <li>&ldquo;Craft&rdquo; (rather than just articulate) an insight so it is evocative, breathing life into creative briefs/documents so they inspire.</li>
  <li><div>Connect a shopper insight to a corresponding consumer insight (insight connectivity): How does the life of the shopper outside of the store (the consumer&rsquo;s life) effect what they do in the store (the shopper&rsquo;s life)?</div></li>
</ul>

When I use the $content variable in a node template, though, the values of the CCK fields are printing as well. I did a print_r($node) to see what was happening, and this is what I get (some elements stripped out for brevity):

stdClass Object (
  [nid] => 383
  [status] => 1
  [created] => 1323794850
  [vid] => 383
  [title] => Advanced Consumer and Shopper Insights
  [body] =>

The word “insight” is one of the most misunderstood and misused words in the marketing world today, but it is also one of the most important. As consumers become more fragmented and individualized, they will increasingly look for brands that represent some aspect of who they are. Brands will have to understand their target from an insights perspective. It will no longer be sufficient to settle for target generalizations.

In this seminar participants will take his/her knowledge and application of insights to an entirely new level. This seminar will teach attendees how to:

    Identify real insights and distinguish them from generalizations, significantly improving the quality of an organization’s insights.
    “Craft” (rather than just articulate) an insight so it is evocative, breathing life into creative briefs/documents so they inspire.
    Connect a shopper insight to a corresponding consumer insight (insight connectivity): How does the life of the shopper outside of the store (the consumer’s life) effect what they do in the store (the shopper’s life)?

Date and Time: 
April 16, 2012
Session Number: 
S1
Session Type: 
Advanced Learning Session
Sold Out: 
Open
Homepage Eligibilty: 
Yes)

The last chunk of the body element (starting with Date and Time) are all CCK field names and values. Why are they included as part of the body? And what can I do if I don't want them displaying?

1 Answer 1

2

CCK fields, by default, are rendered into $content. The order depends on their order on the Manage Fields tab.

To not do this, edit the content type, and goto the Display Fields (or goto /admin/content/node-type/my-content-type/display).

Then set the fields/labels as Hidden or Excluded. I am spacing on the exact difference (too long since I set this up in Drupal 6), but I normally just use Hidden.

5
  • Here's a question: if you set them as hidden, are they ALWAYS hidden? The reason I ask is because our site has two templates - one for desktop and one for mobile (I know, a single responsive design would take care of that, but the desktop site is an older one that we just didn't have time to redo, and there's only a small portion of content that we want available to mobile users) - so I need a way to make sure the fields are able to be hidden on the mobile template but visible on the desktop template.
    – EmmyS
    Feb 23, 2012 at 21:37
  • There's actually a separate tab under Display for mobile devices (don't know if it's always there, or available because we have the mobile tools module installed.) In any case, I checked the exclude box for the fields I don't want to display, saved, and refreshed my mobile browser (yes, all caches cleared, both drupal and mobile.) The fields are still displaying as part of $content.
    – EmmyS
    Feb 23, 2012 at 21:39
  • Not sure what is going on your site, but I checked a few our our Drupal 6 sites and we almost always use hidden instead of excluded. My very hazy recollection is that hidden keeps it out of content, and excluded keeps the field out of the $node object, but as I sais it has been a while since I set up displays on a Drupal 6 site.
    – mpdonadio
    Feb 25, 2012 at 13:49
  • So you're using the hidden value of the Label dropdown? Because (on my site, at least) there is no Hidden checkbox that applies to the entire field like Exclude. I tried that, but all it hides is the label - the field values are still there.
    – EmmyS
    Feb 27, 2012 at 15:11
  • That just hides the label. Also set the dropdown under Teaser, Fullnode, etc to Hidden.
    – mpdonadio
    Feb 27, 2012 at 15:13

Your Answer

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

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