Anyone have any ideas on how I could reference a custom D7 field and use it as a token. The field in question is actually a term reference (autocomplete field). I know how to create tokens, just finding it difficult to reference Drupal 7 fields. I plan on using it to create a custom path, with pathauto.

node module uses

        case 'body':
        case 'summary':
          if (!empty($node->body)) {
            $item = $node->body[$node->language][0];
            $column = ($name == 'body') ? 'value' : 'summary';
            $instance = field_info_instance('node', 'body', $node->type);
            $replacements[$original] = $sanitize ? _text_sanitize($instance, $node->language, $item, $column) : $item[$column];
          }

Could i not do the same with a custom field?

CommentFileSizeAuthor
#8 Screenshot-1.png14.13 KBrogical
#8 Screenshot-2.png101.51 KBrogical
#4 token-sadness.jpg390.27 KBNickWebman

Comments

vglocus’s picture

There should be a token available.

If you have a taxonomy field named field_example there should be a token [node:field-example:name] (the term name).
Look under the Node tab.

Best of luck.

davidd07’s picture

Ok im looking under path auto settings /patterns, and there definately no field_type tokens. Just Drupals default fields. I always thought for custom fields you need to create your own token?

NickWebman’s picture

davidd07: I'm trying to do the exact same thing. Fields are not showing for me as Tokens in Pathauto... and it sure would help if they did.

NickWebman’s picture

StatusFileSize
new390.27 KB
NickWebman’s picture

http://drupal.org/node/691078

See patch in comment #143

It works. Seems like it should be committed.

dave reid’s picture

Status: Active » Closed (duplicate)

This is a duplicate of #691078: Field tokens

Sborsody’s picture

@#1 vglocus,

Entity API and Entity Tokens modules provide that too. Check if you are using them.

rogical’s picture

Version: 7.x-1.0-beta1 » 7.x-1.0-beta2
Status: Closed (duplicate) » Active
StatusFileSize
new101.51 KB
new14.13 KB

I think this is not a duplicate of #691078: Field tokens

The core fields do have tokens, but external custom fields don't.

Please see the attachment.

the field field_example, field_recruit, field_mail doesn't show in token.

dave reid’s picture

Status: Active » Closed (duplicate)

Yes, this is in fact a duplicate of #691078: Field tokens and it would be up to the modules providing those field types to also provide tokens once 691078 lands.

janvdp’s picture

I use this comment to subscribe...