Creating alias when posting an article

7 years 2 months ago #290959 by haidinh
Hi,

My webiste is in Vietnamese and when I post an article via CB, an alias of the article is created but it change all special alias into a dash '-' I want the specials characters to be relevant Latin characters and I tried to change the following code in the file components/com_comprofiler/plugin/user/plug_cbblogs/models/joomla25.php


private static function getTitleAlias( $title )
{
$alias = str_replace( '-', ' ', $title );
$alias = trim( cbIsoUtf_strtolower( $alias ) );
$alias = preg_replace( '/(\s|[^A-Za-z0-9\-])+/', '-', $alias );
$alias = trim( $alias, '-' );
return $alias;
}


into following code:


private static function getTitleAlias( transliterateString( $title ) )
{
$transliterationTable = array('á' => 'a', 'Á' => 'A', 'à' => 'a', 'À' => 'A', 'ả' => 'a', 'Ả' => 'A', 'ã' => 'a', 'Ã' => 'A', 'ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A', 'ẳ' => 'a', 'Ẳ' => 'A', 'ẵ' => 'a', 'Ẵ' => 'A', 'ặ' => 'a', 'Ặ' => 'A', 'ấ' => 'a', 'Ấ' => 'A', 'ầ' => 'a', 'Ầ' => 'A', 'ẩ' => 'a', 'Ẩ' => 'A', 'ẫ' => 'a', 'Ẫ' => 'A', 'ậ' => 'a', 'Ậ' => 'A', 'đ' => 'd', 'Đ' => 'D', 'ó' => 'o', 'Ó' => 'O', 'ò' => 'o', 'Ò' => 'O', 'ỏ' => 'o', 'Ỏ' => 'O', 'õ' => 'o', 'Õ' => 'O', 'ọ' => 'o', 'Ọ' => 'O', 'ố' => 'o', 'Ố' => 'O', 'ồ' => 'o', 'Ồ' => 'O', 'ổ' => 'o', 'Ổ' => 'O', 'ỗ' => 'o', 'Ỗ' => 'O', 'ộ' => 'o', 'Ộ' => 'O', 'ớ' => 'o', 'Ớ' => 'O', 'ờ' => 'o', 'Ờ' => 'O', 'ở' => 'o', 'Ở' => 'O', 'ỡ' => 'o', 'Ỡ' => 'O', 'ợ' => 'o', 'Ợ' => 'O', 'é' => 'e', 'É' => 'E', 'è' => 'e', 'È' => 'E', 'ẻ' => 'e', 'Ẻ' => 'E', 'ẽ' => 'e', 'Ẽ' => 'E', 'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E', 'ễ' => 'e', 'Ễ' => 'E', 'ệ' => 'e', 'Ệ' => 'E', 'í' => 'i', 'Í' => 'I', 'ì' => 'i', 'Ì' => 'I', 'ỉ' => 'i', 'Ỉ' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I', 'ị' => 'i', 'Ị' => 'I', 'ú' => 'u', 'Ú' => 'U', 'ù' => 'u', 'Ù' => 'U', 'ủ' => 'u', 'Ủ' => 'U', 'ũ' => 'u', 'Ũ' => 'U', 'ụ' => 'u', 'Ụ' => 'U', 'ứ' => 'u', 'Ứ' => 'U', 'ừ' => 'u', 'Ừ' => 'U', 'ử' => 'u', 'Ử' => 'U', 'ữ' => 'u', 'Ữ' => 'U', 'ự' => 'u', 'Ự' => 'U', ' ' => '-', "'" => '', '&' => '');
$title = str_replace(array_keys($transliterationTable), array_values($transliterationTable), $title);

$alias = str_replace( '-', ' ', $title );
$alias = trim( cbIsoUtf_strtolower( $alias ) );
$alias = preg_replace( '/(\s|[^A-Za-z0-9\-])+/', '-', $alias );
$alias = trim( $alias, '-' );
return $alias;
}


But it makes the site down.

Can anybody know how to correct it?

Thanks,

Hai

Please Log in to join the conversation.

7 years 2 months ago #290986 by krileon
Replied by krileon on topic Creating alias when posting an article
Install latest CB 2.x release then within Joomla global configuration enable unicode aliases under SEO parameters. We use Joomlas function now for creating aliases.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 2 months ago #290999 by haidinh
Replied by haidinh on topic Creating alias when posting an article
Thank you Krileon,

Do you know in which file Joomla creating the alias?

Hai

Please Log in to join the conversation.

7 years 2 months ago #291017 by krileon
Replied by krileon on topic Creating alias when posting an article
Why is that relevant? You only need to update CB then in Joomla global configuration enable unicode aliases. Then your aliases should generate perfectly fine. This won't have any affect on existing aliases of course unless you edit and re-save them for it to generate the alias again.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

7 years 2 months ago #291021 by haidinh
Replied by haidinh on topic Creating alias when posting an article
Hi Krileon,

The matter is that I cannot use Joomla alias either, even when I turn on the Unicode mode.

The reason is that, in Vietnamese, there are some special charaters and in unisode alias these characters are kept.

For example, if the title is "Mẹo giúp thực phẩm cả tháng không hỏng"

The alias will be: "mẹo-giúp-thực-phẩm-cả-tháng-không-hỏng"

But sometimes it becomes like below or like in the attached file.

"m%E1%BA%B9o+gi%C3%BAp+th%E1%BB%B1c+ph%E1%BA%A9m+c%E1%BA%A3+th%C3%A1ng+kh%C3%B4ng+h%E1%BB%8Fng"

And cannot be read by human.

What I want is to change special charaters into relevant Latin characters. for example. ẹ => e, ú => u, ự => u, ẩ => a, ả => a, á => a, ô => o, ỏ => o...

Then the alias will become:

"meo-giup-thuc-pham-ca-thang-khong-hong"

By that way, the alias can be read.

I will use the array like this:


$transliterationTable = array('á' => 'a', 'Á' => 'A', 'à' => 'a', 'À' => 'A', 'ả' => 'a', 'Ả' => 'A', 'ã' => 'a', 'Ã' => 'A', 'ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A', 'ẳ' => 'a', 'Ẳ' => 'A', 'ẵ' => 'a', 'Ẵ' => 'A', 'ặ' => 'a', 'Ặ' => 'A', 'ấ' => 'a', 'Ấ' => 'A', 'ầ' => 'a', 'Ầ' => 'A', 'ẩ' => 'a', 'Ẩ' => 'A', 'ẫ' => 'a', 'Ẫ' => 'A', 'ậ' => 'a', 'Ậ' => 'A', 'đ' => 'd', 'Đ' => 'D', 'ó' => 'o', 'Ó' => 'O', 'ò' => 'o', 'Ò' => 'O', 'ỏ' => 'o', 'Ỏ' => 'O', 'õ' => 'o', 'Õ' => 'O', 'ọ' => 'o', 'Ọ' => 'O', 'ố' => 'o', 'Ố' => 'O', 'ồ' => 'o', 'Ồ' => 'O', 'ổ' => 'o', 'Ổ' => 'O', 'ỗ' => 'o', 'Ỗ' => 'O', 'ộ' => 'o', 'Ộ' => 'O', 'ớ' => 'o', 'Ớ' => 'O', 'ờ' => 'o', 'Ờ' => 'O', 'ở' => 'o', 'Ở' => 'O', 'ỡ' => 'o', 'Ỡ' => 'O', 'ợ' => 'o', 'Ợ' => 'O', 'é' => 'e', 'É' => 'E', 'è' => 'e', 'È' => 'E', 'ẻ' => 'e', 'Ẻ' => 'E', 'ẽ' => 'e', 'Ẽ' => 'E', 'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E', 'ễ' => 'e', 'Ễ' => 'E', 'ệ' => 'e', 'Ệ' => 'E', 'í' => 'i', 'Í' => 'I', 'ì' => 'i', 'Ì' => 'I', 'ỉ' => 'i', 'Ỉ' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I', 'ị' => 'i', 'Ị' => 'I', 'ú' => 'u', 'Ú' => 'U', 'ù' => 'u', 'Ù' => 'U', 'ủ' => 'u', 'Ủ' => 'U', 'ũ' => 'u', 'Ũ' => 'U', 'ụ' => 'u', 'Ụ' => 'U', 'ứ' => 'u', 'Ứ' => 'U', 'ừ' => 'u', 'Ừ' => 'U', 'ử' => 'u', 'Ử' => 'U', 'ữ' => 'u', 'Ữ' => 'U', 'ự' => 'u', 'Ự' => 'U', ' ' => '-', "'" => '', '&' => '');



to change the file in Joomla core.

Please tell me if you know how to do that.

Thank you,

Hai
Attachments:

Please Log in to join the conversation.

7 years 2 months ago #291092 by krileon
Replied by krileon on topic Creating alias when posting an article
Your issue is probably with the database then. Ensure your collation is set correctly to UTF8 Unicode for all your database tables. Aside from that post on Joomla forums if the alias function isn't working as you're expecting as again we're just using Joomlas function now.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.172 seconds

Facebook Twitter LinkedIn