|
Vấn đề hiển thị alias tiếng Việt với utf-8 ứng dụng cho SEO/SEF |
|
|
|
|
Written by Administrator
|
|
Wednesday, 07 July 2004 19:00 |
|
Bài viết này tham khảo qua bài viết của kochin tại: http://www.joomla.org.tw/component/option,com_smf/Itemid,180/topic,2901.msg9217 Và được bổ sung bởi viet4777 - luyenkim.net Đặt vấn đề: - Từ joomla 1.5, khi bạn đặt tiêu đề bài viết xong, nếu bạn không đặt tiêu đề cho trường tiêu đề alias khi đó Joomla sẽ tự động thay lấy nội dung từ tiêu đề bài viết, chuyển thành chữ thường.
- Nếu bạn sử dụng tiếng Việt Unicode có dấu (dấu mũ, râu, sắc, huyền, hỏi ngã và nặng), sẽ có khá nhiều ký tự có dấu sẽ bị cắt.
Giải pháp: - Sử dụng phương án của kochin: khi đó ký tự tiếng Việt vẫn được giữ nguyên, nghĩa là bạn sẽ thấy status của IE hay FF hiển thị đúng nội dung tiếng Việt.
Cách làm như sau: Thay đổi nội dung các hàm trong các file sau đây: Thay hàm stringURLSafe() trong libraries/joomla/filter/filteroutput.php bằng nội dung sau: function stringURLSafe($string) { //remove any '-' from the string they will be used as concatonater $str = str_replace('-', ' ', $string);
$lang =& JFactory::getLanguage(); $str = $lang->transliterate($str);
// remove any duplicate whitespace, and ensure all characters are alphanumeric //$str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); $str = preg_replace(array('/\s+/', '/\./'), array('-', '_'), $str);
// lowercase and trim $str = trim(strtolower($str)); return $str; }
Thay đổi hàm transliterate() trong file libraries/joomla/language/language.php bằng nội dung sau: function transliterate($string) { //$string = htmlentities(utf8_decode($string)); $string = htmlentities($string, ENT_COMPAT, 'UTF-8'); $string = preg_replace( array('/ß/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'), array('ss',"$1","$1".'e',"$1"), $string);
return $string; }
Tuy nhiên, khi bạn click vào link này, ở ô địa chỉ, các ký tự unicode sẽ bị mã hóa. Để chuyển toàn bộ ký tự có dấu thành ký tự không dấu, các bạn bổ sung thêm theo hướng dẫn ở mục 2. - Để hiển thị tiếng Việt, việc chúng ta cần làm là tạo lập 1 bảng ký tự ánh xạ và sử dụng hàm strtr để làm việc thay thế này.
function stringURLSafe($string) { $trans = array( "đ"=>"d","ă"=>"a","â"=>"a","á"=>"a","à"=>"a","ả"=>"a","ã"=>"a","ạ"=>"a", "ấ"=>"a","ầ"=>"a","ẩ"=>"a","ẫ"=>"a","ậ"=>"a", "ắ"=>"a","ằ"=>"a","ẳ"=>"a","ẵ"=>"a","ặ"=>"a", "é"=>"e","è"=>"e","ẻ"=>"e","ẽ"=>"e","ẹ"=>"e", "ế"=>"e","ề"=>"e","ể"=>"e","ễ"=>"e","ệ"=>"e", "í"=>"i","ì"=>"i","ỉ"=>"i","ĩ"=>"i","ị"=>"i", "ư"=>"u","ô"=>"o","ơ"=>"o","ê"=>"e", "Ư"=>"u","Ô"=>"o","Ơ"=>"o","Ê"=>"e", "ú"=>"u","ù"=>"u","ủ"=>"u","ũ"=>"u","ụ"=>"u", "ứ"=>"u","ừ"=>"u","ử"=>"u","ữ"=>"u","ự"=>"u", "ó"=>"o","ò"=>"o","ỏ"=>"o","õ"=>"o","ọ"=>"o", "ớ"=>"o","ờ"=>"o","ở"=>"o","ỡ"=>"o","ợ"=>"o", "ố"=>"o","ồ"=>"o","ổ"=>"o","ỗ"=>"o","ộ"=>"o", "ú"=>"u","ù"=>"u","ủ"=>"u","ũ"=>"u","ụ"=>"u", "ứ"=>"u","ừ"=>"u","ử"=>"u","ữ"=>"u","ự"=>"u",'ý'=>'y','ỳ'=>'y','ỷ'=>'y','ỹ'=>'y','ỵ'=>'y', 'Ý'=>'Y','Ỳ'=>'Y','Ỷ'=>'Y','Ỹ'=>'Y','Ỵ'=>'Y', "Đ"=>"D","Ă"=>"A","Â"=>"A","Á"=>"A","À"=>"A","Ả"=>"A","Ã"=>"A","Ạ"=>"A", "Ấ"=>"A","Ầ"=>"A","Ẩ"=>"A","Ẫ"=>"A","Ậ"=>"A", "Ắ"=>"A","Ằ"=>"A","Ẳ"=>"A","Ẵ"=>"A","Ặ"=>"A", "É"=>"E","È"=>"E","Ẻ"=>"E","Ẽ"=>"E","Ẹ"=>"E", "Ế"=>"E","Ề"=>"E","Ể"=>"E","Ễ"=>"E","Ệ"=>"E", "Í"=>"I","Ì"=>"I","Ỉ"=>"I","Ĩ"=>"I","Ị"=>"I", "Ư"=>"U","Ô"=>"O","Ơ"=>"O","Ê"=>"E", "Ư"=>"U","Ô"=>"O","Ơ"=>"O","Ê"=>"E", "Ú"=>"U","Ù"=>"U","Ủ"=>"U","Ũ"=>"U","Ụ"=>"U", "Ứ"=>"U","Ừ"=>"U","Ử"=>"U","Ữ"=>"U","Ự"=>"U", "Ó"=>"O","Ò"=>"O","Ỏ"=>"O","Õ"=>"O","Ọ"=>"O", "Ớ"=>"O","Ờ"=>"O","Ở"=>"O","Ỡ"=>"O","Ợ"=>"O", "Ố"=>"O","Ồ"=>"O","Ổ"=>"O","Ỗ"=>"O","Ộ"=>"O", "Ú"=>"U","Ù"=>"U","Ủ"=>"U","Ũ"=>"U","Ụ"=>"U", "Ứ"=>"U","Ừ"=>"U","Ử"=>"U","Ữ"=>"U","Ự"=>"U",);
//remove any '-' from the string they will be used as concatonater $str = str_replace('-', ' ', $string); $str = strtr($str, $trans); $lang =& JFactory::getLanguage(); $str = $lang->transliterate($str);
// remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); // $str = preg_replace(array('/\s+/', '/\./'), array('-', '_'), $str); //$str = utf8_accents_to_ascii($str); // lowercase and trim $str = trim(strtolower($str)); return $str; }
Nội dung modified file filteroutput.php (tôi để ở txt, nhớ chuyển utf-8). Rất cảm ơn bạn đã ghé thăm thế giới của Kulkul - Welcome to kulkul's world - Nguyễn Thanh Thảo
Related news items:
Newer news items:
Older news items:
|
|
Last Updated ( Thursday, 19 June 2008 20:57 )
|
|
|
Newsflash 5
| Joomla! 1.5 - 'Experience the Freedom'!. It has never been easier to create your own dynamic Web site. Manage all your content from the best CMS admin interface and in virtually any language you speak. |
|
|
|
Newsflash 1
Joomla! makes it easy to launch a Web site of any kind. Whether you want a brochure site or you are building a large online community, Joomla! allows you to deploy a new site in minutes and add extra functionality as you need it. The hundreds of available Extensions will help to expand your site and allow you to deliver new services that extend your reach into the Internet. |
|
|
|
Newsflash 2
The one thing about a Web site, it always changes! Joomla! makes it easy to add Articles, content, images, videos, and more. Site administrators can edit and manage content 'in-context' by clicking the 'Edit' link. Webmasters can also edit content though a graphical Control Panel that give you complete control over your site. |
|
|
|
Newsflash 3
With a library of hundreds of free Extensions, you can add what you need as your site grows. Don't wait, look through the Joomla! Extensions library today. |
|
|
|
|
|
Advertisement
Exchange Links
xahoihoctap.net
The social network for learning and self study.
Luyenkim.Net
Luyenkim.Net! The first Vietnamese website for metallurgy, materials science and engineering.
JoomlaCode
JoomlaCode, development and distribution made easy.
Joomla! Extensions
Joomla! Components, Modules, Plugins and Languages by the bucket load.
Joomla! Shop
For all your Joomla! merchandise.
|
bạn có thể xem hình lỗi ở đây
Mong bạn xem và fix giúp mình
các file mình thay đổi
http://panudes.com/tolearn/tieng-viet/filteroutput.php
http://panudes.com/tolearn/tieng-viet/language.php
Cám ơn trứoc có bài viết hãy email cho mình nhé
Tất cả các sản phẩm của chúng tôi, hiện tại chủ yếu là các plugin, sẽ và đang được ứng dụng trên website này.
hoặc demo ?
ngại sửa lắm (lười)
có lẽ bác post các file đã sửa nén trong 1 file zip thì tiện hơn chăng ?
thx