помогите с скриптом DLE

M
На сайте с 22.05.2010
Offline
16
865

Установил модуль "вывод последних коментариев на сайт".Нужно сделать что б название статьи обрезалось после 30 символов.

Вот собственно сами файлы, подскажите где что поменять.

Файлик lastcomments.php

<?php
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}

$userid = intval( $_REQUEST['userid'] );
$_SESSION['referrer'] = $_SERVER['REQUEST_URI'];


$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
$where = array ();

if( $userid ) {
$where[] = PREFIX . "_comments.user_id='$userid'";
$user_query = "do=lastcomments&amp;userid=" . $userid;
} else
$user_query = "do=lastcomments";

if( $allow_list[0] != "all" ) {

$join = "LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id ";

if( $config['allow_multi_category'] ) {

$where[] = PREFIX . "_post.category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]'";

} else {

$where[] = PREFIX . "_post.category IN ('" . implode( "','", $allow_list ) . "')";

}

} else {

$join = "";

}

if( $config['allow_cmod'] ) {

$where[] = PREFIX . "_comments.approve='1'";

}

if( count( $where ) ) {

$where = implode( " AND ", $where );
$where = "WHERE " . $where;

} else
$where = "";



$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_comments " . $join . $where;
$row_count = $db->super_query( $sql_count );

if( $row_count['count'] ) {

include_once ENGINE_DIR . '/classes/comments.class.php';

$comments = new DLE_Comments( $db, $row_count['count'], $config['comm_nummers'] );

$comments->query = "SELECT " . PREFIX . "_comments.id, post_id, " . PREFIX . "_comments.user_id, " . PREFIX . "_comments.date, " . PREFIX . "_comments.autor as gast_name, " . PREFIX . "_comments.email as gast_email, text, ip, is_register, name, " . USERPREFIX . "_users.email, news_num, " . USERPREFIX . "_users.comm_num, user_group, reg_date, signature, foto, fullname, land, icq, " . USERPREFIX . "_users.xfields as xprofile, " . PREFIX . "_post.title, " . PREFIX . "_post.date as newsdate, " . PREFIX . "_post.alt_name, " . PREFIX . "_post.category, " . PREFIX . "_post.flag FROM " . PREFIX . "_comments LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id " . $where . " ORDER BY id desc";

$comments->build_comments('comments.tpl', 'lastcomments' );

$comments->build_navigation('navigation.tpl', false, $user_query);

} else {

msgbox( $lang['all_info'], $lang['err_last'] );

}

?>

Файлик lastcomments_block.php

<?php

if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking Attempt!" );
}


if( !$config['lastcomm_limit'] OR $config['lastcomm_limit'] < 1 ) $limit = 4;
else $limit = $config['lastcomm_limit'];

$lastcomments_block = dle_cache( "lastcomments_block", $config['skin'] );

if( !$lastcomments_block ) {

$db->query( "SELECT comments.post_id, comments.is_register, comments.text, comments.autor, comments.email, post.id, post.date as post_date, post.alt_name, post.category, post.title, post.flag FROM " . USERPREFIX . "_comments as comments, " . USERPREFIX . "_post as post WHERE post.id=comments.post_id ORDER BY comments.date DESC LIMIT 0, $limit" );



while( $row = $db->get_row() ) {

$tpl->load_template( 'lastcomment.tpl' );

if( $row['is_register'] != 1 ) {

if( !empty( $row['email'] ) ) {

if( preg_match( "/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $row['email'] ) ) {

$type = 'mailto:';
} else {

$type = '';
if( strtolower( substr( $row['email'], 0, 3 ) ) == "www" ) $type = 'http://';
}

if( $type == 'mailto:' ) {

$author = $row['autor'];
} else {

$author = "<a href=\"$type" . $row['email'] . "\" targhet=\"_new\">" . $row['autor'] . "</a>" ;
}

} else $author = $row['autor'];

} else {

if( $config['allow_alt_url'] == "yes" ) $author = "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/\">" . $row['autor'] . "</a>";
else $author = "<a href=\"$PHP_SELF?subaction=userinfo&amp;user=" . urlencode( $row['autor'] ) . "\">" . $row['autor'] . "</a>";
}

$row['date'] = strtotime($row['date']);
$row['post_date'] = strtotime($row['post_date']);
$row['category'] = intval( $row['category'] );

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'] ) . "/" . $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'];
}

if( !$config['lastcomm_maxtitle'] OR $config['lastcomm_maxtitle'] < 1 ) $maxtitle = 50;
$maxtitle = $config['lastcomm_maxtitle'];

if( !$config['lastcomm_maxcomment'] OR $config['lastcomm_maxcomment'] < 1 ) $maxcomment = 50;
$maxcomment = $config['lastcomm_maxcomment'];

if( strlen( $row['title']) > $maxtitle AND $maxtitle != 0) $post_title = substr( $row['title'], 0, $maxtitle ) . "...";
else $post_title = $row['title'];

$comment = htmlspecialchars( stripslashes ( $row['text'] ) );
if( strlen( $comment ) > $maxcomment AND $maxcomment != 0) $comment = substr ($comment, 0, $maxcomment) . "...";

$tpl->set( '{author}', $author );
if( $config['allow_lastcomm_hint'] == "yes" ) {

$tpl->set( '[post-link]', "<a onmouseover=\"showhint('{$comment}', this, event, '')\" href=\"" . $full_link . "#comment\">" );
$tpl->set( '[/post-link]', "</a>" );
} else {

$tpl->set( '[post-link]', "<a href=\"" . $full_link . "#comment\">" );
$tpl->set( '[/post-link]', "</a>" );
}
$tpl->set( '{post}', stripslashes( $post_title ) );

$tpl->compile( 'lastcomments_block' );
$tpl->clear();
}

if( $config['allow_lastcomm_hint'] == "yes" ) $tpl->result['lastcomments_block'] = "<script type=\"text/javascript\" src=\"" . $config['http_home_url'] . "engine/skins/default.js\"></script>\r\n".$tpl->result['lastcomments_block'];

$lastcomments_block = $tpl->result['lastcomments_block'];

$db->free();
create_cache( "lastcomments_block", $lastcomments_block, $config['skin'] );
}

?>

Менял тут: if( !$config['lastcomm_maxtitle'] OR $config['lastcomm_maxtitle'] < 1 ) $maxtitle = 50; не помогает:(

Master_globus
На сайте с 15.09.2006
Offline
113
#1

if( !$config['lastcomm_limit'] OR $config['lastcomm_limit'] < 1 ) $limit = 4;

четыре на свою цифру.

Работаю только с diafan.CMS 4.4.0 (http://cms.diafan.ru/cms576/)
Spell
На сайте с 14.07.2006
Offline
72
#2

Попробуйте, для теста, после:

if( !$config['lastcomm_maxtitle'] OR $config['lastcomm_maxtitle'] < 1 ) $maxtitle = 50;
$maxtitle = $config['lastcomm_maxtitle'];

поставить:

$maxtitle = 50;

И посмотреть на результат (сбросить кэш не забудьте).

Я не совсем понимаю, что такое $config['lastcomm_maxtitle']

И это модуль не последних новостей, а последних комментариев.

Spell добавил 14.04.2011 в 17:05

Согласно этой конструкции:

if( strlen( $row['title']) > $maxtitle AND $maxtitle != 0) $post_title = substr( $row['title'], 0, $maxtitle ) . "...";
else $post_title = $row['title'];

Если длина TITLE больше MAXTITLE, и MAXTITLE не равно нулю - производится обрезание TITLE и добавление "..." к хвосту.

Скорее всего у вас где-то в конфиге этого модуля прописано MAXTITLE = 0.

Проверьте, есть ли настройки модуля в админке или в файле.

M
На сайте с 22.05.2010
Offline
16
#3
Master_globus:
if( !$config['lastcomm_limit'] OR $config['lastcomm_limit'] < 1 ) $limit = 4;

четыре на свою цифру.

Это количество выводимых коментариев, это не то...

makslm добавил 14.04.2011 в 17:23

Спасибо за советы сейчас попробую, я выложил всё что относиться к даному модулю... Тоесть 2 файлика

makslm добавил 14.04.2011 в 17:26

Не работает :( наверное скрипт кривой какой-то...

Spell
На сайте с 14.07.2006
Offline
72
#4

Жду ответа

M
На сайте с 22.05.2010
Offline
16
#5
Spell:
Жду ответа

меняю на $maxtitle = 1; ничего не изменяеться, наверное функция вообще не работает...

makslm добавил 14.04.2011 в 17:42

Всё разобрался))

if( !$config['lastcomm_maxtitle'] OR $config['lastcomm_maxtitle'] > 5 ) $maxtitle = 5;

else $maxtitle = $config['lastcomm_maxtitle'];

вот так заработало!)

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий