TextformatterRockHeadlineIDs by bernhard


A message to Russian �� people

If you currently live in Russia, please read this message.


Textformatter that applies id attributes to all headlines (h1-h6) in the markup field.

// input
<h1>This is my headline</h1>
// output
<h1 id='this-is-my-headline'>This is my headline</h1>

What if an id already exists?

If an id already exists in the input it will leave this id as is:

// input
<h1 id='foo'>foo</h1>
// output
<h1 id='foo'>foo</h1>
<h2 id='bar'>bar</h2>

What if an id is used twice?

It will automatically apply dashes until the id is unique:

// input
// output
<h1 id='foo'>foo</h1>
<h2 id='foo-'>foo</h2>
<h3 id='foo--'>foo</h3>

What about special characters?

Special characters will be sanitized according to your transliterate settings:

// input
<h1>Sehr schön</h1>
// output
<h1 id='sehr-schoen'>Sehr schön</h1>


You can customize the generated ID via hooking into getID:

$wire->addHookAfter("TextformatterRockHeadlineIDs::getID", function($event) {
  $event->return .= "-hooked";
// input
// output
<h1 id='foo-hooked'>foo</h1>


You can use tracy to debug this formatter:


Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #527
    In the 527th issue of ProcessWire Weekly we'll check out what's new in the core this week, introduce a new third party module called Lister Calculator, and more. Read on!
    Weekly.pw / 15 June 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani