Slugfy() Formater does not accept accentuation

======== TEMPLATE BUG FORM ========

Wappler Version : 2.5.4
Operating System : Windows 10Pro

Slugfy() Formater does not accept accentuation

This doesn’t look like a slugify formatter problem, but an error returned by your database.

Are you sure your database table collation/encoding is utf8, so it accepts Unicode characters?

I made this change and it worked,

function formatter_slugify($val) {
if ($val == NULL) return NULL;
$a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ"!@#$%&*()_-+={[}]/?;:.,\\\'<>°ºª';
$b = 'aaaaaaaceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';   
$val = utf8_decode($val);
$val = strtr($val, utf8_decode($a), $b);
$val = strip_tags(trim($val));
$val = strval($val);
$val = preg_replace('/[^\w\s]/', '', $val);
$val = strtolower($val);
$val = preg_replace('/[_\s]+/', '-', $val);
$val = preg_replace('/-+/', '-', $val);
$val = preg_replace('/^-/', '', $val);
return $val;

}

If you use your own custom formatter it is better to place it in a different file and give it a unique name. Now you will loose your changes when there is an update in the current formatters.

Create a file like custom.php or myFormatters.php in the formatters folder.

<?php

namespace lib\core;

function formatter_slugify2($val) {
  if ($val == NULL) return NULL;
  $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ"!@#$%&*()_-+={[}]/?;:.,\\\'<>°ºª';
  $b = 'aaaaaaaceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr';   
  $val = utf8_decode($val);
  $val = strtr($val, utf8_decode($a), $b);
  $val = strip_tags(trim($val));
  $val = strval($val);
  $val = preg_replace('/[^\w\s]/', '', $val);
  $val = strtolower($val);
  $val = preg_replace('/[_\s]+/', '-', $val);
  $val = preg_replace('/-+/', '-', $val);
  $val = preg_replace('/^-/', '', $val);
  return $val;
}

Use it like {{$_POST.titulo.slugify2()}}.

I don’t want to use mine, I want the wappler tidy.

The wappler formatter does not accept accentuation

can you fix it please

Copy pasted your code, but I get this error:

The custom.php is here:

image

I’ve set it in Wappler like so:

image

What am I doing wrong?

Have you uploaded the modified file to your server?

Not entirely sure how to check, because I’m working on Docker Local. Where can I find where the custom.php should have been uploaded to? I’ve did a redeploy, but that made no difference in the error.

Edit: made a mistake on my side @Teodor, it works now!

Hello,

Is there any plan to have this included in Wappler? :grinning:

Thanks!

This has been fixed in Wappler 4.6

1 Like

This topic was automatically closed after 47 hours. New replies are no longer allowed.