By Groupe Média Théapolis on Wednesday, 03 July 2019
Posted in General Issues
Replies 5
Likes 0
Views 601
Votes 0
Hello,

To avoid the use of whimsical names (eg EmmAnUelle PalLA), you have sent us a code that allows you to put only the first letters in capital letters (image 1).
It can be found in: JoomlaFolder/media/com_easysocial/apps/fields/user/joomla_fullname/joomla_fullname.php

That's great.

However, some first names (eg Jean-Paul, Pierre-Francois) require two capital letters, one for each word (image 2).

Is there a way to code that ?

Best regards.
The method "ucwords" can only change letters of a first word into upper case. It's not going to be possible to also detect names that contains hyphens "-".

The concept to achieve this would be, you will need to customize and tweak the code by separating the hyphen and only then apply the uppercase characters on each of the word. After that, you will need to re-join the string again.

I am sorry but unfortunately this is beyond the scope of our support and we are unable to provide you with the codes.
·
Wednesday, 03 July 2019 23:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

We will try to find a solution. If we find, we will send it to you.

Thank you for your assistance.

Cordially.
·
Thursday, 04 July 2019 16:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there,

Thanks for your understanding. By the way, maybe you can refer listed links below for more informations.

- https://stackoverflow.com/questions/5546120/php-capitalize-after-dash
- https://www.php.net/manual/en/function.ucwords.php
·
Thursday, 04 July 2019 17:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello,

We just found this little trick that works since it allows to capitalize each word :

// Get the first name.
$firstName = isset($data['first_name']) ? ucwords(strtolower($data['first_name'])) : '';
$middleName = isset($data['middle_name']) ? ucwords(strtolower($data['middle_name'])) : '';
$lastName = isset($data['last_name']) ? ucwords(strtolower($data['last_name'])) : '';

$firstName = mb_convert_case (mb_strtolower ($firstName, "UTF-8" ), MB_CASE_TITLE, "UTF-8" ) ;
$middleName = mb_convert_case (mb_strtolower ($middleName, "UTF-8" ), MB_CASE_TITLE, "UTF-8" ) ;
$lastName = mb_convert_case (mb_strtolower ($lastName, "UTF-8" ), MB_CASE_TITLE, "UTF-8" ) ;

Best regards.
·
Thursday, 04 July 2019 17:33
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi there,

Nicely done. By the way, glad to hear that your issue has been resolved now.
·
Thursday, 04 July 2019 17:43
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post