المشاركة الأصلية كتبت بواسطة: عبدالاله الهذلي قمت بستخدام
CODE
$num =$PowerBB->_CONF['template']['_CONF']['info_row']['portal_news_along'];
$PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text'] = $PowerBB->Powerparse->replace($PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text']);
$PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text'] = $PowerBB->Powerparse->censor_words($PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text']);
$PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text'] = $PowerBB->functions->words_count($PowerBB->_CONF['template']['while']['LastNews_subjectList'][$this->x_loop]['text'],$num);
ولكن عند إستخدام عدد كلمات الخبر بعدد محدد مثلًا أتوقع راح يخرب القالب بالكامل بسبب عدم إغلاق الكود مثلا:

ستحتاج function خاص يستثني عدم احتساب HTML tags ضمن عملية اقتصاص الكلمات
في الكود الخاص بك استبدل words_count بـ substr_close_tags
ثم افتح ملف: includes/functions.class.php
وابحث عن :
CODE
function words_count($string,$words_count)
واضف اعلاها :
CODE
function substr_close_tags($code, $limit)
{
if ( strlen($code) <= $limit )
{
return $code;
}
$html = substr($code, 0, $limit);
preg_match_all ( "#<([a-zA-Z]+)#", $html, $result );
foreach($result[1] AS $key => $value)
{
if ( strtolower($value) == 'br' )
{
unset($result[1][$key]);
}
}
$openedtags = $result[1];
preg_match_all ( "#</([a-zA-Z]+)>#iU", $html, $result );
$closedtags = $result[1];
foreach($closedtags AS $key => $value)
{
if ( ($k = array_search($value, $openedtags)) === FALSE )
{
continue;
}
else
{
unset($openedtags[$k]);
}
}
if ( empty($openedtags) )
{
if ( strpos($code, ' ', $limit) == $limit )
{
return $html."...";
}
else
{
return substr($code, 0, strpos($code, ' ', $limit))."...";
}
}
$position = 0;
$close_tag = '';
foreach($openedtags AS $key => $value)
{
$p = strpos($code, ('</'.$value.'>'), $limit);
if ( $p === FALSE )
{
$code .= ('</'.$value.'>');
}
else if ( $p > $position )
{
$close_tag = '</'.$value.'>';
$position = $p;
}
}
if ( $position == 0 )
{
return $code;
}
return substr($code, 0, $position).$close_tag."...";
}