با سلام دوستان این دومین پست من تو دیتالایفه
دوستانی که از custom استفاده میکنند یک مشکل دارند.
مشکل تو موضوعات تو در تو هست. اگر تو تگ custom آی دی موضوع والد رو میگذاشتید مطالب زیر موضوعات رو نشون نمیداد. با این هک این مشکل حل میشه.
برای نصب مراحل زیر رو طی کنید:
1. فایل ضمیمه
show.gamacat.zip 3,08 کيلوبايت 120 دانلود فایل
رو به هاستتون آپلود کنید.
2. تو فایل index.php قبل از کد:
کد زیر رو قرار دهید
3. تو فایل templates.class.php قبل از کد:
این کد رو قرار دهید:
4. مرحله پایانی تو فایل engine\modules\functions.php قبل از کد :
این کد رو قرار دهید:
برای استفاده تو هر جایی از قالب که خواستید از این تگ استفاده کنید:
هر مشکلی داشتید در میان بگذارید.
دوستانی که از custom استفاده میکنند یک مشکل دارند.
مشکل تو موضوعات تو در تو هست. اگر تو تگ custom آی دی موضوع والد رو میگذاشتید مطالب زیر موضوعات رو نشون نمیداد. با این هک این مشکل حل میشه.
برای نصب مراحل زیر رو طی کنید:
1. فایل ضمیمه
رو به هاستتون آپلود کنید.
2. تو فایل index.php قبل از کد:
if (strpos ( $tpl->copy_template, "{custom" ) !== false) {
کد زیر رو قرار دهید
if (strpos ( $tpl->copy_template, "{gamacat" ) !== false) {
$tpl->copy_template = preg_replace ( "#\\{gamacat category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "gamacat_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $tpl->copy_template );
}
$tpl->copy_template = preg_replace ( "#\\{gamacat category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "gamacat_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $tpl->copy_template );
}
3. تو فایل templates.class.php قبل از کد:
if (strpos ( $this->template, "[aviable=" ) !== false) {
این کد رو قرار دهید:
if (strpos ( $this->template, "{gamacat" ) !== false) {
$this->template = preg_replace ( "#\\{gamacat category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "gamacat_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $this->template );
}
$this->template = preg_replace ( "#\\{gamacat category=['\"](.+?)['\"] template=['\"](.+?)['\"] aviable=['\"](.+?)['\"] from=['\"](.+?)['\"] limit=['\"](.+?)['\"] cache=['\"](.+?)['\"]\\}#ies", "gamacat_print('\\1', '\\2', '\\3', '\\4', '\\5', '\\6', '{$dle_module}')", $this->template );
}
4. مرحله پایانی تو فایل engine\modules\functions.php قبل از کد :
function custom_print($custom_category,
این کد رو قرار دهید:
function gamacat_print($custom_category, $custom_template, $aviable, $custom_from, $custom_limit, $custom_cache, $do) {
global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module;
$do = $do ? $do : "main";
$aviable = explode( '|', $aviable );
if( ! (in_array( $do, $aviable )) and ($aviable[0] != "global") ) return "";
$custom_category = $db->safesql( str_replace( ',', '|', $custom_category ) );
$custom_from = intval( $custom_from );
$custom_limit = intval( $custom_limit );
$thisdate = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60) );
if( intval( $config['no_date'] ) ) $where_date = " AND date < '" . $thisdate . "'";
else $where_date = "";
$tpl = new dle_template( );
$tpl->dir = TEMPLATE_DIR;
if( $custom_cache == "yes" ) $config['allow_cache'] = "yes";
else $config['allow_cache'] = false;
if( $is_logged and ($user_group[$member_id['user_group']]['allow_edit'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) $config['allow_cache'] = false;
$content = dle_cache( "custom", "cat_" . $custom_category . "template_" . $custom_template . "from_" . $custom_from . "limit_" . $custom_limit, true );
if( $content ) {
return $content;
} else {
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
if( $user_group[$member_id['user_group']]['allow_short'] ) $stop_list = "";
if( $cat_info[$custom_category]['news_sort'] != "" ) $news_sort = $cat_info[$custom_category]['news_sort']; else $news_sort = $config['news_sort'];
if( $cat_info[$custom_category]['news_msort'] != "" ) $news_msort = $cat_info[$custom_category]['news_msort']; else $news_msort = $config['news_msort'];
$custom_category = str_replace( "|", "','", $custom_category );
$where_category = "category in (select id FROM " . PREFIX . "_category where parentid IN ('" . $custom_category . "') )";
$where_category .= " or category in ('" . $custom_category . "') ";
if ($config['allow_fixed']) $fixed = "fixed desc, ";
else $fixed = "";
$sql_select = "SELECT id, autor, date, short_story, full_story, xfields, title, category, alt_name, comm_num, allow_comm, allow_rate, rating, vote_num, news_read, flag, editdate, editor, reason, view_edit, tags FROM " . PREFIX . "_post WHERE " . $where_category . " AND approve" . $where_date . " ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit;
include (ENGINE_DIR . '/modules/show.gamacat.php');
if( $config['files_allow'] == "yes" ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
$tpl->result['content'] = show_attach( $tpl->result['content'], $attachments );
}
create_cache( "custom", $tpl->result['content'], "cat_" . $custom_category . "template_" . $custom_template . "from_" . $custom_from . "limit_" . $custom_limit, true );
}
return $tpl->result['content'];
}
global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module;
$do = $do ? $do : "main";
$aviable = explode( '|', $aviable );
if( ! (in_array( $do, $aviable )) and ($aviable[0] != "global") ) return "";
$custom_category = $db->safesql( str_replace( ',', '|', $custom_category ) );
$custom_from = intval( $custom_from );
$custom_limit = intval( $custom_limit );
$thisdate = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60) );
if( intval( $config['no_date'] ) ) $where_date = " AND date < '" . $thisdate . "'";
else $where_date = "";
$tpl = new dle_template( );
$tpl->dir = TEMPLATE_DIR;
if( $custom_cache == "yes" ) $config['allow_cache'] = "yes";
else $config['allow_cache'] = false;
if( $is_logged and ($user_group[$member_id['user_group']]['allow_edit'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) $config['allow_cache'] = false;
$content = dle_cache( "custom", "cat_" . $custom_category . "template_" . $custom_template . "from_" . $custom_from . "limit_" . $custom_limit, true );
if( $content ) {
return $content;
} else {
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
if( $user_group[$member_id['user_group']]['allow_short'] ) $stop_list = "";
if( $cat_info[$custom_category]['news_sort'] != "" ) $news_sort = $cat_info[$custom_category]['news_sort']; else $news_sort = $config['news_sort'];
if( $cat_info[$custom_category]['news_msort'] != "" ) $news_msort = $cat_info[$custom_category]['news_msort']; else $news_msort = $config['news_msort'];
$custom_category = str_replace( "|", "','", $custom_category );
$where_category = "category in (select id FROM " . PREFIX . "_category where parentid IN ('" . $custom_category . "') )";
$where_category .= " or category in ('" . $custom_category . "') ";
if ($config['allow_fixed']) $fixed = "fixed desc, ";
else $fixed = "";
$sql_select = "SELECT id, autor, date, short_story, full_story, xfields, title, category, alt_name, comm_num, allow_comm, allow_rate, rating, vote_num, news_read, flag, editdate, editor, reason, view_edit, tags FROM " . PREFIX . "_post WHERE " . $where_category . " AND approve" . $where_date . " ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit;
include (ENGINE_DIR . '/modules/show.gamacat.php');
if( $config['files_allow'] == "yes" ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
$tpl->result['content'] = show_attach( $tpl->result['content'], $attachments );
}
create_cache( "custom", $tpl->result['content'], "cat_" . $custom_category . "template_" . $custom_template . "from_" . $custom_from . "limit_" . $custom_limit, true );
}
return $tpl->result['content'];
}
برای استفاده تو هر جایی از قالب که خواستید از این تگ استفاده کنید:
{gamacat category="38" template="test" aviable="global" from="0" limit="4" cache="no"}
هر مشکلی داشتید در میان بگذارید.
تاریخ انتشار: 14 تير 1389
آخرین ویرایش: 19 تير 1389
ارسال کننده: szabeh
برچسب ها: , , مشکل, custom_from, custom_category, if, custom_limit, strpos, استفاده, tplresultcontent, tplcopy_template, custom, if, false, ویرایش فایل, فایل, موضوعات, news_sort
kp45، saron و اشکان و 16 نفر دیگر تشکر کردهاند.
