вопрос
Здравствуйте, как подправить этот код, что бы выводить теги через tpl, а не через echo $iComm?
Дело в том, что я немного изменил подключение этого модуля (теперь он подключается через {lastcomm} в main.tpl).
Дело в том, что я немного изменил подключение этого модуля (теперь он подключается через {lastcomm} в main.tpl).
<?php
/*====================================================
Author: RooTM
------------------------------------------------------
Web-site: http://weboss.net/
-----------------------------------------------------
Доработал скрипт: ПафНутиЙ
Web-site: http://pafnuty.name
icq: 817233
=====================================================*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$max_text = 1000; //Максимальное количество символов в комментарии
$max_title = 300; //Максимальное количество символов в заголовке новости
$max_comm = 10; //Количество комментариев в блоке
$is_change = false;
if ($config['allow_cache'] != "yes") { $config['allow_cache'] = "yes"; $is_change = true;}
$iComm = dle_cache( "news_comm_", $config['skin'] );
if( $iComm === false ) {
$tooday = date ('Y-m-d H:i:s', $_TIME); //Определяем сегодняшний день
$db->query( "SELECT c.post_id, c.is_register, c.text, c.autor, c.email, p.id, p.date as newsdate, p.title, p.category, p.comm_num, p.alt_name, p.flag FROM " . PREFIX . "_comments as c, " . PREFIX . "_post as p WHERE p.id=c.post_id AND c.approve=1 ORDER BY c.date DESC LIMIT 0, " . $max_comm );
while ( $row = $db->get_row() ) {
//======================================================================
$row['category'] = intval( $row['category'] ); // это для правильного определения ссылки на новость, опубликованную в нескольких категориях
if($row['comm_num'] / $config['comm_nummers'] <= 1){
$on_page = '';
}else{
$on_page = 'page,1,'.reset(explode( '.' , $row['comm_num'] / $config['comm_nummers'] )).',';
}
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" .$on_page. $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] .$on_page. $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) .$on_page. $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$full_link = $full_link.'#comment';
//======================================================================
$text = $row['text'];
if( dle_strlen( $row['text'], $config['charset'] ) > $max_text ) $text = dle_substr( $row['text'], 0, $max_text, $config['charset'] ) . " ...";
//======================================================================
$title = $row['title'];
$long_title = $row['title'];
if( dle_strlen( $row['title'], $config['charset'] ) > $max_title ) $title = dle_substr( $row['title'], 0, $max_title, $config['charset'] ) . " ...";
//======================================================================
$tpl->load_template ( 'lastcomm.tpl' );
$tpl->set ( '{text}', $text );
$tpl->set ( '{title}', $title );
$tpl->set ( '{long_title}', $long_title );
$tpl->set ( '{author}', $row['autor'] );
$tpl->set ( '{full_link}', $full_link );
$tpl->set ( '{comm_num}', $row['comm_num'] );
$tpl->compile ( 'lastcomm' );
$iComm .= $tpl->result['lastcomm'];
$tpl->global_clear ();
//======================================================================
}
$db->free();
if(!$iComm) $iComm = '<div align="center">Нет комментариев</div>';
create_cache( "news_comm_", $iComm, $config['skin'] );
}
//======================================================================
if( $user_group[$member_id['user_group']]['allow_hide'] ) $iComm = preg_replace( "'\[hide\](.*?)\[/hide\]'si", "\\1", $iComm );
else $iComm = preg_replace ( "'\[hide\](.*?)\[/hide\]'si", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $iComm );
//======================================================================
echo '<ul class="lastcomm">' .$iComm. '</ul> <div align="right" style="font-size: 9px; padding-right: 3px;">Copyright © <a href="http://weboss.net/" target="_blank" style="text-decoration: none; font-size: 9px;">WEBoss.Net</a></div>';
if ($is_change) $config['allow_cache'] = false;
?>
В файле index.php (/engine/modules/main.php)
Использовать переменную $tpl->result['lastcomm']
вместо $iComm
Использовать переменную $tpl->result['lastcomm']
вместо $iComm
<?php
/*====================================================
Author: RooTM
------------------------------------------------------
Web-site: http://weboss.net/
-----------------------------------------------------
Доработал скрипт: ПафНутиЙ
Web-site: http://pafnuty.name
icq: 817233
=====================================================*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$max_text = 1000; //Максимальное количество символов в комментарии
$max_title = 300; //Максимальное количество символов в заголовке новости
$max_comm = 10; //Количество комментариев в блоке
$is_change = false;
if ($config['allow_cache'] != "yes") { $config['allow_cache'] = "yes"; $is_change = true;}
$tpl->result['lastcomm'] = dle_cache( "news_comm_", $config['skin'] );
if( $tpl->result['lastcomm'] === false ) {
$tooday = date ('Y-m-d H:i:s', $_TIME); //Определяем сегодняшний день
$db->query( "SELECT c.post_id, c.is_register, c.text, c.autor, c.email, p.id, p.date as newsdate, p.title, p.category, p.comm_num, p.alt_name, p.flag FROM " . PREFIX . "_comments as c, " . PREFIX . "_post as p WHERE p.id=c.post_id AND c.approve=1 ORDER BY c.date DESC LIMIT 0, " . $max_comm );
$tpl->load_template ( 'lastcomm.tpl' );
while ( $row = $db->get_row() ) {
//======================================================================
$row['category'] = intval( $row['category'] ); // это для правильного определения ссылки на новость, опубликованную в нескольких категориях
if($row['comm_num'] / $config['comm_nummers'] <= 1){
$on_page = '';
}else{
$on_page = 'page,1,'.reset(explode( '.' , $row['comm_num'] / $config['comm_nummers'] )).',';
}
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" .$on_page. $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] .$on_page. $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) .$on_page. $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
$full_link = $full_link.'#comment';
//======================================================================
$text = $row['text'];
if( dle_strlen( $row['text'], $config['charset'] ) > $max_text ) $text = dle_substr( $row['text'], 0, $max_text, $config['charset'] ) . " ...";
//======================================================================
$title = $row['title'];
$long_title = $row['title'];
if( dle_strlen( $row['title'], $config['charset'] ) > $max_title ) $title = dle_substr( $row['title'], 0, $max_title, $config['charset'] ) . " ...";
//======================================================================
$tpl->set ( '{text}', $text );
$tpl->set ( '{title}', $title );
$tpl->set ( '{long_title}', $long_title );
$tpl->set ( '{author}', $row['autor'] );
$tpl->set ( '{full_link}', $full_link );
$tpl->set ( '{comm_num}', $row['comm_num'] );
$tpl->compile ( 'lastcomm' );
$tpl->clear();
//======================================================================
}
$db->free();
if(!$tpl->result['lastcomm']) $tpl->result['lastcomm'] = '<div align="center">Нет комментариев</div>';
create_cache( "news_comm_", $tpl->result['lastcomm'], $config['skin'] );
}
//======================================================================
if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['lastcomm'] = preg_replace( "'\[hide\](.*?)\[/hide\]'si", "\\1", $tpl->result['lastcomm'] );
else $tpl->result['lastcomm'] = preg_replace ( "'\[hide\](.*?)\[/hide\]'si", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['lastcomm'] );
//======================================================================
$tpl->result['lastcomm'] = '<ul class="lastcomm">' .$tpl->result['lastcomm']. '</ul> <div align="right" style="font-size: 9px; padding-right: 3px;">Copyright © <a href="http://weboss.net/" target="_blank" style="text-decoration: none; font-size: 9px;">WEBoss.Net</a></div>';
if ($is_change) $config['allow_cache'] = false;
?>