Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Модули » Вывод последних комментариев

Вывод последних комментариев


     08.07.2014    комментарии    Все вопросы » Модули    2706

вопрос
Здравствуйте. Стоял у меня простенький модуль вывода последних комментариев на ДЛЕ 9.8, но после обновления до 10.2 стал работать как-то некорректно. Вот его код:



Проблема в том, что перестала формироваться правильно ссылка и имеет такой вид:

_http://mu_site/index.php?newsid=#comment

Все десять ссылок получаются такими одинаково кривыми. Мож кто знает в чём тут косяк?

Ответил: rocksmart


заменить

 if ($conf_url == "yes")


на

 if ($conf_url)


Или так

<?
//////////////////////////////////////////////////////////////
//=========================================================+//

//////////////////////////////////////////////////////////////
//Настроечки небольшие
$comm_num = 10; //Лимит коментариев выводимых в блоке




////////////////////////////////
//Создаем запрос к базе данных на вывод комментов
$query_comm_temp = "SELECT distinct pos.comm_num,pos.alt_name,pos.title,pos.date FROM (select distinct post_id from ".PREFIX ."_comments order by id desc limit $comm_num) com left join ".PREFIX ."_post pos on pos.id=com.post_id limit ".$comm_num;
$query_comm = $db->query($query_comm_temp);
$comment_tpl = "";
///////////////////////////////
//Выводим комментарии в цикле
while ($post = $db->get_row($query_comm))
{
    $post['date'] = strtotime($post['date']);
if( $config['allow_alt_url'] ) {
            
            if( $config['seo_type'] == 1 OR $config['seo_type'] == 2  ) {
                
                if( $row['category'] and $config['seo_type'] == 2 ) {
                    
                    $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
        
        }
        
$comment_tpl .= " <img src= {THEME}/images/ball.gif /> <a href=\"".$full_link."#comment\">".$post['title']." (".$post['comm_num'].")</a><br />";
}
$lastcomment = $comment_tpl;



?>

4 комментария

list
Юзер

list - 8 июля 2014 20:21 -

Спасибо, первый вариант почти идеально.
Ссылка получается вот такая _http://mu_site/2014/06/27/zdes_novost.html#comment
Но при нажатии конвертируется в _http://mu_site/category/7824-zdes_novost.html#comment
Зато всё открывается.

А второй вариант вот так выходит
_http://mu_site/-.html#comment

rocksmart
Юзер

rocksmart - 8 июля 2014 21:21 -

Извиняюсь поторопился с ответом.

//////////////////////////////////////////////////////////////
//=========================================================+//

//////////////////////////////////////////////////////////////
//Настроечки небольшие
$comm_num = 10; //Лимит коментариев выводимых в блоке




////////////////////////////////
//Создаем запрос к базе данных на вывод комментов
$query_comm_temp = "SELECT distinct pos.comm_num,pos.id,pos.category,pos.alt_name,pos.title,pos.date FROM (select distinct post_id from ".PREFIX ."_comments order by id desc limit $comm_num) com left join ".PREFIX ."_post pos on pos.id=com.post_id limit ".$comm_num;
$query_comm = $db->query($query_comm_temp);
$comment_tpl = "";
///////////////////////////////
//Выводим комментарии в цикле
while ($post = $db->get_row($query_comm)){
$post['category'] = intval($post['category'] );


if( $config['allow_alt_url'] ) {
            
            if( $config['seo_type'] == 1 OR $config['seo_type'] == 2  ) {
                
                if( $post['category'] and $config['seo_type'] == 2 ) {
                    
                    $full_link = $config['http_home_url'] . get_url( $post['category'] ) . "/" . $post['id'] . "-" . $post['alt_name'] . ".html";
                
                } else {
                    
                    $full_link = $config['http_home_url'] . $post['id'] . "-" . $post['alt_name'] . ".html";
                
                }
            
            } else {
                
                $full_link = $config['http_home_url'] . date( 'Y/m/d/', $post['date'] ) . $post['alt_name'] . ".html";
            }
        
        } else {
            
            $full_link = $config['http_home_url'] . "index.php?newsid=" . $post['id'];
        
        }
    $post['date'] = strtotime($post['date']);      
$comment_tpl .= " <img src= {THEME}/images/ball.gif /> <a href=\"".$full_link."#comment\">".$post['title']." (".$post['comm_num'].")</a><br />";
}
$lastcomment = $comment_tpl;

list
Юзер

list - 8 июля 2014 21:36 -

Отлично!

mujik
Юзер

mujik - 8 января 2015 16:18 -

rocksmart, Спасибо большое, очень помог!

Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх