I'm trying to get the following snippet to work. This is the snippet provided in the README file as an fill-in-the-blank template for generating a node title automatically from a given CCK field rather than the usual subject line. I assume I'm supposed to replace [field_testtext-raw] with the name of the CCK field I want to automatically generate titles from, (in my case the name of the CCK field is I want to use is [message_body_field]), but that's not working. The published page generated using this php snippet just shows the static machine-readable name of the field [message_body_field] as the title, rather than what the user enters in the corresponding field as the title. Any thoughts?

  $token = '[field_testtext-raw]';
  if (empty($token)) {
    return '[type]';
  }
  else {
    return $token;
  } 

Comments

carlogen’s picture

You should install token module as well.

http://drupal.org/project/token

It will give you all the tokens you can use.
I hope it helps

fumbling’s picture

Thanks. I thought I had token installed, but you were right, I didn't. I installed it, and now the code seems to work partially, but not fully. the [type] part works, but the [cck field here] part does not. Do I need to go into the token file and do something to get that to work? Any other thoughts? I assumed from the example snippet that I just replaced [field_testtext-raw] with [cck field here] is that right?

Drupalot.com - ask & answer Drupal questions

fumbling’s picture

What I missed was adding the -raw to [message_body_field]. Once it read [message_body_field-raw] it worked. Thanks again.

Drupalot.com - ask & answer Drupal questions