code lấy kí 160 kí tự làm mô tả JohnCMS

Thứ Tư, 15 tháng 5, 2013

Thấy nhiều anh em xin quá, hôm nay ngồi làm TUT cho ae 
TUT này mình viết nên đừng có bảo copy xong share nhá 
Code này trong bản gốc cũng có rồi, tại mọi người không để ý thôi 
Hướng dẫn:
Bước 1:
mở forum/index.php tìm

$headmod = $id ? 'forum,' . $id : 'forum';

 


thêm bên dưới

$postres = mysql_fetch_assoc(mysql_query("SELECT `forum`.* FROM `forum` LEFT JOIN `users` ON `forum`.`user_id` = `users`.`id` WHERE `forum`.`type` = 'm' AND `forum`.`refid` = '$id' ORDER BY `forum`.`id` ASC LIMIT 1"));
$tukhoa = $textl;
$mota = bbcode::notags($postres['text']);

 


Xong. Lưu vào nhé! 

Bước 2:
mở incfiles/head.php tìm

$headmod = isset($headmod) ? mysql_real_escape_string($headmod) : '';

 


thêm bên dưới

if (strlen($tukhoa) < 5)
$tukhoa = $set['meta_key'];
if (strlen($mota) < 5)
$mota = $set['meta_desc'];
$mota = html_entity_decode($mota, ENT_QUOTES, 'UTF-8');
$tukhoa = html_entity_decode($tukhoa, ENT_QUOTES, 'UTF-8');

 


tìm tiếp:

(!empty($set['meta_key']) ? "\n" . '<meta name="keywords" content="' . $set['meta_key'] . '" />' : '') .
(!empty($set['meta_desc']) ? "\n" . '<meta name="description" content="' . $set['meta_desc'] . '" />' : '') .

 


thay tất cả thành:

"\n" . '<meta name="keywords" content="'.mb_substr($tukhoa, 0, 160).'" />' .
"\n" . '<meta name="description" content="'.mb_substr($mota, 0, 160).'" />' .

 


 

Không có nhận xét nào:

Đăng nhận xét