Slug dependent field with accented characters
  • Hi.
    In one of my models i needed a slug (linked) field.
    The problem was that i'm using spanish texts, and a title like "Sólo una prueba más" was "slugified" as "slo-una-prueba-ms".
    All accented chars disappear.

    Just by adding this line...
    text = text.normalize('NFD'); the first line of the url_title function in linked_field_formatters.js (or fuel.min.js), did the job.

    Maybe it's a good thing to add in the future for all the non-english titles. ;)

    I hope this helps!
  • I didn't even know that function existed. What line did you add it?
  • First line of the function at fuel/modules/fuel/assets/js/fuel/linked_field_formatters.js

    // standard slugify borrowed from
    function url_title(text) {
    text = text.normalize('NFD');
    text = text.replace(/([^_-a-zA-Z0-9\s]|\,|\&)+/gi, '');
    text = text.replace(/\s+/gi, "-");
    text = text.toLowerCase();
    return text;

    Maybe there's a better place for doing this?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!