SanitizerEasySlugger by Robin S

Allows the use of the EasySlugger library as Sanitizer methods.

Sanitizer EasySlugger

A module for ProcessWire CMS/CMF. Allows the use of the EasySlugger library as Sanitizer methods.

Installation


Install the Sanitizer EasySlugger module.

Usage


The module adds four new sanitizer methods.

slugger($string, $options)

Similar to $sanitizer->pageName() - I'm not sure if there are any advantages over that method. Included because it is one of the methods offered by EasySlugger.

$slug = $sanitizer->slugger('Lorem Ipsum');
// Result: lorem-ipsum

utf8Slugger($string, $options)

Creates slugs from non-latin alphabets.

$slug = $sanitizer->utf8Slugger('这个用汉语怎么说');
// Result: zhe-ge-yong-han-yu-zen-me-shuo

seoSlugger($string, $options)

Augments the string before turning it into a slug. The conversions are related to numbers, currencies, email addresses and other common symbols.

$slug = $sanitizer->seoSlugger('The price is $5.99');
// Result: the-price-is-5-dollars-99-cents

See the EasySlugger readme for some more examples.

seoUtf8Slugger($string, $options)

A combination of utf8Slugger() and seoSlugger().

$slug = $sanitizer->seoUtf8Slugger('价钱是 $5.99');
// Result: jia-qian-shi-5-dollars-99-cents

$options argument

Each of the methods can take an $options array as a second argument.

  • separator (string): the character that separates words in the slug. Default: -
  • unique (bool): Determines whether a random suffix is added at the end of the slug. Default: false
$slug = $sanitizer->utf8Slugger('这个用汉语怎么说', ['separator' => '_', 'unique' => true]);
// Result: zhe_ge_yong_han_yu_zen_me_shuo_3ad66c4

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

Latest news

  • ProcessWire Weekly #519
    In the 519th issue of ProcessWire Weekly we'll check out a new third party module called RockForms, introduce the latest ProcessWire core updates, and more. Read on!
    Weekly.pw / 20 April 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

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK