Any functions built-in to slugify a string?
Shadowdare
MVP
Does Vanilla currently have a function built-in to convert a string to a slug/URL code? Looking for a formatter on the PHP side, not the existing one written in JS for category settings.
Add Pages to Vanilla with the Basic Pages app
0
Comments
Like
slugify()in functions.general.php? 😉or
Gdn_Format::url()grep is your friend.
I was thinking of importing a library such as Slug Generator for an addon, but those would be quite useful. Thank you both for pointing those out! Do either of those algorithms handle special/international characters (Cyrillic, etc) well?
Add Pages to Vanilla with the Basic Pages app
slugify uses iconv to "transliterate"
// transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);Gdn_Format::url()just replaces unicode characters with hyphens.I'll go with
slugify()for this project. It doesn't seem to handle special inputs such as "富士山", which outputs "n-a" (wherein the result came out empty) instead of "fu-shi-shan", for example, but I can always use a library to handle this when the need arises. Thanks for the replies! 😀Add Pages to Vanilla with the Basic Pages app