Skip to main content

Post categories

  • Drupal Tips & Tricks
  • Drupal Howtos
  • Drupal Themes
  • X Twitter
  • youtube
Home
Drupal 4U
Drupal Development, Drupal Web Design, Drupal SEO
  • 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
98

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
98
1
min read
A- A+
  • facebook-f
  • twitter
  • envelope
  • print

Contact Drupal 4U

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

Contact Us

We aim to reply the latest within 48h.

About Drupal 4U

We are a group of Drupal designers, developers and webmasters and we launched this website to share our experience and knowledge with you. Drupal is a free software package that allows you to easily organize, manage and publish your content, with an endless variety of customization. Drupal is open source software maintained and developed by a very large community of developers and users.

  • X Twitter
  • youtube

Drupal Services

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

Drupal 4U

  • Services
  • Showcases
  • Themes
  • Blog
  • About

Drupal Links

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

Footer menu

  • Contact
Home
Drupal 4U
Drupal Development, Drupal Web Design, Drupal SEO
  • Home
  • Showcases
  • Services
  • Blog
  • Themes
  • About
  • Contact
Clear keys input element