Tự get mô tả cho johncms

S

sontung

New Member
Vào incfiles/functions.php thêm đoạn code sau
#####
PHP:
function xemtruoc ( $str,$length) {
if (strstr($str,'
')) return '';  $result = substr ( strip\es( $str ), 0,$length );  while( true ) {    if( $tmp = substr ( strip\es( $str ),$length, 1 ) ) {      if ( $tmp == ' ' ) break;      $result .= $tmp;    } else break;    $length  ;  }  return $result; }
####
Sửa file incfiles/core.php
Tìm
PHP:
require_once ('func.php');
Thêm vào sau:
PHP:
if ($id) {    $wtf = mysql_fetch_assoc(mysql_query("SELECT `text` FROM `forum` WHERE `id` = $id"));   $prev = xemtruoc($wtf['text'],200); }
Sauđó sửa file incfiles/head.php
Thay thế
PHP:
if (!empty ($set['meta_desc'])) echo '<meta name="description" content="' .$set['meta_desc'] . '" />';
bằng
PHP:
if (!$prev) echo '<meta name="description" content="'.$set['meta_desc'].'">'; else echo '<meta name="description" content="'.$prev.'">';
 

Facebook Comments

Similar threads

Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
2K
AdminAdmin is verified member.
Admin
Back
Top