
Представляем адаптацию хака ShortMain 1.0 для DLE 10.5 - 10.2, позволяет выводить разные виды краткой новости на главной странице, что не возможно в стандартной версии скрипта DataLife Engine. Хак для Dle ShortMain 1.0 обновился с версии DLE 10.2 до DLE 10.4 и выше. Адаптированный хак для недавно вышедшего релиза DataLife Engine поможет вам вывести разные виды краткой новости на главной странице, ведь без данного хака это не возможно сделать.
Вид новостей разный
Админ часть где нужно задать tpl файл
Установка модифицированного хака ShortMain 1.0 [DLE 10.2 - 10.4]
1) Сделать SQL запрос, если вы не знаете как сделать запрос SQL, прочитать можете здесь :
ALTER TABLE `dle_category` ADD `main_tpl` VARCHAR( 40 ) NOT NULL AFTER `full_tpl`;
Если у вас другой префикс базы данных (то есть название таблиц dle_category) , меняем dle на свой, если нет оставляем как есть
2) В файле engine/modules/show.short.php НАЙТИ И УДАЛИТЬ :
if( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' );
else $tpl->load_template( 'shortstory.tpl' );
if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) { $xfound = true; $xfields = xfieldsload();}
else $xfound = false;
if( count( $banners ) AND $config['allow_banner'] AND !$smartphone_detected) {
$news_c = 1;
if( isset( $ban_short ) ) {
for($indx = 0, $max = sizeof( $ban_short['top'] ), $banners_topz = ''; $indx < $max; $indx ++)
if( $ban_short['top'][$indx]['zakr'] ) {
$banners_topz .= $ban_short['top'][$indx]['text'];
unset( $ban_short['top'][$indx] );
}
for($indx = 0, $max = sizeof( $ban_short['cen'] ), $banners_cenz = ''; $indx < $max; $indx ++)
if( $ban_short['cen'][$indx]['zakr'] ) {
$banners_cenz .= $ban_short['cen'][$indx]['text'];
unset( $ban_short['cen'][$indx] );
}
for($indx = 0, $max = sizeof( $ban_short['down'] ), $banners_downz = ''; $indx < $max; $indx ++)
if( $ban_short['down'][$indx]['zakr'] ) {
$banners_downz .= $ban_short['down'][$indx]['text'];
unset( $ban_short['down'][$indx] );
}
$middle = floor( $config['news_number'] / 2 );
$middle_s = floor( ($middle - 1) / 2 );
$middle_e = floor( $middle + (($config['news_number'] - $middle) / 2) + 1 );
}
}
3) В файле engine/modules/show.short.php НАЙТИ :
while ( $row = $db->get_row( $sql_result ) ) {
НИЖЕ ВСТАВИТЬ :
$cat_tpl = explode( ',', $row['category'] );
if($category_id and $cat_info[$category_id]['short_tpl'] != '' ) {
$tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' );
} elseif( !$category_id and $cat_info[$cat_tpl[0]]['main_tpl'] != '') {
$tpl->load_template( $cat_info[$cat_tpl[0]]['main_tpl'] . '.tpl' );
} else {
$tpl->load_template( 'shortstory.tpl' );
}
if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) { $xfound = true; $xfields = xfieldsload();}
else $xfound = false;
if( count( $banners ) AND $config['allow_banner'] AND !$smartphone_detected) {
$news_c = 1;
if( isset( $ban_short ) ) {
for($indx = 0, $max = sizeof( $ban_short['top'] ), $banners_topz = ''; $indx < $max; $indx ++)
if( $ban_short['top'][$indx]['zakr'] ) {
$banners_topz .= $ban_short['top'][$indx]['text'];
unset( $ban_short['top'][$indx] );
}
for($indx = 0, $max = sizeof( $ban_short['cen'] ), $banners_cenz = ''; $indx < $max; $indx ++)
if( $ban_short['cen'][$indx]['zakr'] ) {
$banners_cenz .= $ban_short['cen'][$indx]['text'];
unset( $ban_short['cen'][$indx] );
}
for($indx = 0, $max = sizeof( $ban_short['down'] ), $banners_downz = ''; $indx < $max; $indx ++)
if( $ban_short['down'][$indx]['zakr'] ) {
$banners_downz .= $ban_short['down'][$indx]['text'];
unset( $ban_short['down'][$indx] );
}
$middle = floor( $config['news_number'] / 2 );
$middle_s = floor( ($middle - 1) / 2 );
$middle_e = floor( $middle + (($config['news_number'] - $middle) / 2) + 1 );
}
}
4) В файле engine/inc/categories.php НАЙТИ (2 РАЗА) :
if ( $_POST['short_tpl'] ) {
$url = @parse_url ( $_POST['short_tpl'] );
$file_path = dirname (clear_url_dir($url['path']));
$tpl_name = pathinfo($url['path']);
$tpl_name = totranslit($tpl_name['basename']);
if ($file_path AND $file_path != ".") $tpl_name = $file_path."/".$tpl_name;
$short_tpl = $tpl_name;
} else $short_tpl = "";
НИЖЕ ВСТАВИТЬ (2 РАЗА) :
if ( $_POST['main_tpl'] ) {
$url = @parse_url ( $_POST['main_tpl'] );
$file_path = dirname (clear_url_dir($url['path']));
$tpl_name = pathinfo($url['path']);
$tpl_name = totranslit($tpl_name['basename']);
if ($file_path AND $file_path != ".") $tpl_name = $file_path."/".$tpl_name;
$main_tpl = $tpl_name;
} else $main_tpl = "";
5) В файле engine/inc/categories.php НАЙТИ
full_tpl='$full_tpl'
ЗАМЕНИТЬ НА :
full_tpl='$full_tpl', main_tpl='$main_tpl'
6) В файле engine/inc/categories.php НАЙТИ :
<div class="form-group">
<label class="control-label col-lg-2">{$lang['cat_f_tpl']}</label>
<div class="col-lg-10">
<input style="width:100%;max-width:200px;" type="text" name="full_tpl">.tpl <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="{$lang['cat_f_tpl_hit']}" >?</span>
</div>
</div>
НИЖЕ ВСТАВИТЬ :
<div class="form-group">
<label class="control-label col-lg-2">{$lang['cat_m_tpl']}</label>
<div class="col-lg-10">
<input style="width:100%;max-width:200px;" type="text" name="main_tpl">.tpl <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="{$lang[cat_m_tpl_hit]}" >?</span>
</div>
</div>
7) В файле engine/inc/categories.php НАЙТИ :
short_tpl, full_tpl
Заменить на :
short_tpl, full_tpl, main_tpl
8) В файле engine/inc/categories.php НАЙТИ :
'$short_tpl', '$full_tpl'
Заменить на :
'$short_tpl', '$full_tpl', '$main_tpl'
9) В файле engine/inc/categories.php НАЙТИ :
<div class="form-group">
<label class="control-label col-lg-2">{$lang['cat_f_tpl']}</label>
<div class="col-lg-10">
<input style="width:100%;max-width:200px;" type="text" name="full_tpl" value="{$row['full_tpl']}">.tpl <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="{$lang['cat_f_tpl_hit']}" >?</span>
</div>
</div>
НИЖЕ ВСТАВИТЬ :
<div class="form-group">
<label class="control-label col-lg-2">{$lang['cat_m_tpl']}</label>
<div class="col-lg-10">
<input style="width:100%;max-width:200px;" type="text" name="main_tpl" value="{$row['main_tpl']}">.tpl <span class="help-button" data-rel="popover" data-trigger="hover" data-placement="right" data-content="{$lang[cat_m_tpl_hit]}" >?</span>
</div>
</div>
10) В файле language/Russian/adminpanel.lng Найти :
'cat_f_tpl' => "Шаблон полной новости",
ВЫШЕ ВСТАВИТЬ :
'cat_m_tpl' => "Шаблон короткой новости на главной",
'cat_m_tpl_hit' => "Помимо назначения отдельного шаблона для данной категории, вы можете указать только отдельный файл шаблона для вывода кратких новостей на главной. Вы можете оставить это поле пустым, тогда будет загружаться стандартный файл шаблона <b>shortstory.tpl</b>",
Автор : Dmitry Dark5ider
Адаптация : Gameer
Версия DLE : 10.2 - 10.4 и возможно дле 10.5
Если вы думаете, что тоже самое самое можно сделать через тег {custom}, то ошибаетесь
Этот хак позволит выводить разные типы оформления для краткой новости через тег {content}, которые указываются при создании категории. Без него, вы не выведите разные шаблоны для краткой через тег {content}.
Этот хак позволит выводить разные типы оформления для краткой новости через тег {content}, которые указываются при создании категории. Без него, вы не выведите разные шаблоны для краткой через тег {content}.
Скачать хаки дле у нас, хак ShortMain 1.0 [DLE 10.2 - 10.4]