0

In Drupal, when you create a field, there is the option "Text Processing". You can select either "plain text" or "Filtered text".

When I create a field with "Filtered text", I am unable to use it as a token.

For example, on my content type "content_page", I have a long_text field called "intro_text". The "Text Processing" is set to "Filtered text".

If I use this field as a token, it just won't work. This happens in a variety of modules including Meta Tag and Path Auto.

Even if I set the text format in the token, it still does not render. (e.g. [node:field-intro-text:plain_text]).

If I change the "Text Processing" to "Plain text", it works, so the problem lies with "Text Processing".

How can I get the token to work when it set to "Filtered text"?

1

I am using this module Token Insert Text

Perhaps you need this to get it to work. (I know my version is outdated, I did this a long time ago)

enter image description here

Then go to admin/config/content/ckeditor/edit/Advanced and under EDITOR APPEARANCE

enter image description here

Scroll alway the way down and click save.

  • I don't see the option for "allow tokens". Thanks for your help! – big_smile Jun 6 '15 at 13:47
  • I just checked, I was wrong there isn't any. Are you using CKeditor for your Filter HTML? – No Sssweat Jun 6 '15 at 15:29
  • I have tried with and without CKeditor, but can't get it to work. Thanks for your help. – big_smile Jun 6 '15 at 15:34
  • edited my answer, I hope this helps. – No Sssweat Jun 6 '15 at 15:48
0

You want Advanced Text Formatter:

Options

  • Trim length: The maximum number of characters the a field can be. Set this to 0 if you don't want to cut the text. Otherwise, input a positive integer.
  • Ellipsis: If checked, a "..." will be added if a field was trimmed.
  • Word Boundary: If checked, this field be trimmed only on a word boundary. This is guaranteed to be the maximum characters stated or less. If there are no word boundaries this could trim a field to nothing.
  • Token Replace: Run token replace on this field.
  • Filter: Filter the value of this field.

EDIT

Text Processing on a Text Field or Text Area Field has nothing to do as to whether or not the field can be used as a token.

A token is a symbol to be replaced by text. For security reasons tokens are usually sanitized by the system when they are placed into content -- and malicious content is not cleaned by the system but usually usually clobbered (destructively) out of the source input.

Eg, a text field with like <span class="foo">Hello Hello</span> would not be seen as "hello hello" as a token but an empty value because <span> tags are removed by sanitization (removed and not wiped).

If you want to try to use a text field with an Input Filter you then have to supply field formatters for the item that will display the item cleanly for other fields expecting certain values such as Paths or Meta Tags. Eg, paths do not contain markup, and I assume meta-tags should not contain html entities.

One option is the Formatted Field Tokens. Which would allow you to define a token that uses a field formatter (similiar to your example of [node:field-intro-text:plain_text]) but even plain text would not replace ' ' in a title with say '-' or '_' to be a valid Path url. You would likely also need to enable the Transliteration module for your field to assure the text input is valid (and binding transliteration to your custom field(s) may take some code. the FileField Sources module does this for file titles and paths on the filesystem if you want to see example code that does this).

  • But how would I use that in fields provided by modules such as Meta Tag and Path auto? Thanks for your help! – big_smile Jun 5 '15 at 18:30
  • 1
    Your question is confusing. Pathauto will use the Path field for Nodes by default -- no other configuration is needed you simply need Pathauto and the Token module enabled. This module allows you to create a custom text Field for any entity in drupal and empower it to use Tokens. – tenken Jun 5 '15 at 19:35
  • Let's say I want to use my "Intro Text" field as the URL alias. In path auto, I could just put in the token for the into alias field. But it will ignore it the field uses formatted text. Obviously, I don't want HTML in the alias, but Path auto (or the token) should strip it out. The same goes for the Meta Tag module. I want to use the "intro Text" field for the Meta Description tag, but I can't if intro text is a formatted field. Again, I wouldn't want any formatting in the meta tag, but the module/token would strip that out. – big_smile Jun 5 '15 at 20:59
  • 1
    See my amended answer. If that doesnt give you ideas on a solution I'm outta ideas and goodluck. You should have worded your initial question with the examples in your most recent comment as your initial question was wayyyy too vague on your intended goals and setup. – tenken Jun 5 '15 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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