[DataLife] اعمال محدودیت عنوان و متن مطلب در تگ custom

Silver PC

Well-Known Member
1. فایل index.php را باز کنید کد زیر را پیدا کنید :

کد:
if (strpos ( $tpl->copy_template, "{custom" ) !== false) {
    $tpl->copy_template = preg_replace ( "#\\{custom category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "custom_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $tpl->copy_template );
}

سپس به کد زیر تغییر دهید :

کد:
if (strpos ( $tpl->copy_template, "{custom" ) !== false) {
    $tpl->copy_template = preg_replace ( "#\\{custom category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"] limitt=['\"](.+?)['\"] limitst=['\"](.+?)['\"]\\}#ies", "custom_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}', '\\7', '\\8')", $tpl->copy_template );
}

2. فایل engine/modules/functions.php را باز کنید کد زیر را پیدا کنید :

کد:
function custom_print($custom_category, $custom_template, $aviable, $custom_from, $custom_limit, $custom_cache, $do)

سپس به کد زیر تغییر دهید :

کد:
function custom_print($custom_category, $custom_template, $aviable, $custom_from, $custom_limit, $custom_cache, $do, $custom_limitt, $custom_limitst)

3.فایل engine/modules/show.custom.php را باز کنید کد زیر را پیدا کنید :

کد:
$tpl->set( '{short-story}', stripslashes( $row['short_story'] ) );

در پایین آن کد زیر را قرار دهید :

کد:
    if(strlen($row['title']) > $custom_limitt AND $custom_limitt > 0) {$tpl->set( '{title}', substr($row['title'], 0, $custom_limitt) . " ..." );}
    if(strlen(stripslashes( $row['short_story'] )) > $custom_limitst AND $custom_limitst > 0) {$tpl->set( '{short-story}', substr(stripslashes( $row['short_story'] ), 0, $custom_limitst) . " ..." );}

حالا از تگ custom باید به صورت زیر استفاده کنید :

کد:
{custom category="1" template="test" aviable="global" from="0" limit="3" cache="no" limitt="20" limitst="200"}

کد:
limitt = تعدا کاراکتر عنوان مطلب
limitst = تعداد کاراکتر متن کوتاه مطلب

حالا دو تگ {title} و {short-story} به تعدادی که که در تگ قرار داده اید محدود می شوند


اگر می خواهید محدودیت اعمال نشود تعداد را برار صفر قرار دهید
و حتما به تمام تگ های کاستوم limitt و limitst را اضافه کنید تا تگ کار کند
 

جدیدترین ارسال ها

بالا