أهلا وسهلا بك زائرنا الكريم في منتدى دعم PBBoard الرسمي، لكي تتمكن من المشاركة ومشاهدة جميع أقسام المنتدى وكافة الميزات ، يجب عليك إنشاء حساب جديد بالتسجيل بالضغط هنا أو تسجيل الدخول اضغط هنا إذا كنت عضواً .

طلب تعديل قالب portal_last_news ستحتاجfunction خاص يستثني عدم احتساب HTML tags ضمن ع

ستحتاجfunction خاص يستثني عدم احتساب HTML tags ضمن عملية اقتصاص الكلمات في الكود الخاص بك استبدلwords_count بـsubstr_close_tags ثم افتح ملف:in



look/images/icons/i1.gif طلب تعديل قالب portal_last_news
  03-10-2020 03:00 صباحاً  
معلومات الكاتب ▼
انضم في : 18-07-2009
رقم العضوية : 1
المشاركات : 12,571
الدولة : KSA
الجنس :
الدعوات : 52
قوة السمعة : 74,196
موقعي : زيارة موقعي
المشاركة الأصلية كتبت بواسطة: عبدالاله الهذلي قمت بستخدام
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);



ولكن عند إستخدام عدد كلمات الخبر بعدد محدد مثلًا أتوقع راح يخرب القالب بالكامل بسبب عدم إغلاق الكود مثلا:
MTYwMzkyMQ1212%D8%AA%D9%86%D8%B2%D9%8A%D9%84

ستحتاج 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."...";
}




الساعة الآن 01:51 PM