Skip to main content
  • X Twitter
  • youtube
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact

Breadcrumb

  1. Home
  2. HowTos
  3. Drupal Tokens: How to remove the line-breaking paragraph tag from tokens used within nodes

Drupal Tokens: How to remove the line-breaking paragraph tag from tokens used within nodes

HowTos
February 12, 2016
Profile picture for user drupal
By drupal
  • facebook-f
  • twitter
  • envelope
  • print
104

Tokens are simple strings of text that serve as place holders for an as of yet unknown dynamic value. Tokens allows you to use small place holders to automatically complete tasks. To take a simple example, if you put [site:name] on your site, it will be replaced by the actual name of your site. To take a more complicated example, you can use Token together with the Pathauto module to automatically create URL patterns for your whole site.

When one uses field tokens within a node (Example: [node:field_test_field]) with a standard configuration the line-breaking tag p is added to the printed token. But in many case we only want to print the plain token value. While it is easy to solve the issue using views - by using Rewrite with the option "Strip HTML tags" - it is a little more complicated when using tokens in nodes.

The following solutions worked for us, although we are not sure if there is a more elegant solution:

a) If the node field only contains the token
1. Create or use a text format where the option "Convert line breaks into HTML (i.e. br and p)" is unchecked
2. Assign this text format to the node field

b) If the node field contains various elements and you need to use the option "Convert line breaks into HTML (i.e. br and p)"
1. Create a hidden node field [field_hidden_field] where you print the token [node:field_test_field]
2. Create or use a text format where the option "Convert line breaks into HTML (i.e. br and p)" is unchecked
3. Assign this text format to the hidden node field
4. Reprint the hidden node field using again a token [node:field_hidden_field] in the node field

List of tokens:
https://www.drupal.org/node/390482#drupal7tokenslist

Drupal Tokens: How to remove the line-breaking paragraph tag  from tokens used within nodes
Troubleshooting

Read more articles

Newer
File entity module: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table
Older
How to implement Rooms 7.x-1.8 properly - Problem with full calendar library
  • Log in to post comments
Profile picture for user drupal
drupal
104
1
min read
A- A+
  • facebook-f
  • twitter
  • envelope
  • print

Contact Us

Get in touch for questions and our Drupal development, design and optimization services.

Contact Us

We aim to reply the latest within 48h.

Drupal 4U: Built for AI. Powered by Drupal.

We are a group of Drupal designers, developers and webmasters. We are Drupal experts! We provide comprehensive services that go beyond traditional web development, focusing on how AI understands, interprets, and cites your content. With our deep expertise in Drupal's architecture, we build the intelligent core of your digital presence, ensuring your brand remains authoritative and visible in a world where AI is the primary gatekeeper of information. Partner with us and let's future-proof your digital strategy together.

  • X Twitter
  • youtube

Drupal Services

  • Drupal Web Design
  • Drupal Development
  • Drupal SEO
  • Drupal GEO
  • Drupal Migration

Drupal 4U

  • Services
  • Showcases
  • Themes
  • Blog
  • About

Drupal Links

  • Official Drupal Website
  • Theme Forest
  • Gaivas Themes
  • More Than Themes
  • DXPR: Drupal for Marketers
  • Drupal Answers
2012 - 2025, Drupal 4U

Footer menu

  • Contact
Home
Drupal 4U
Built for AI. Powered by Drupal.
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact
Clear keys input element