Вывод рейтинговых новостей с описанием и картинкой в DLE
Хак позволяет выводить топ новости сайта более красиво, с картинкой и описанием.
Установка:
Открываем файл engine/modules/topnews.php и находим:
$db->query( "SELECT id, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve='1' AND date >= '$this_month' - INTERVAL 1 MONTH AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
Заменить на:
$db->query( "SELECT id, title, date, alt_name, category, short_story, flag FROM " . PREFIX . "_post WHERE approve='1' AND date >= '$this_month' - INTERVAL 7 DAY AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
Найти:
$topnews .= "» " . $link . "<br />";
Заменить на:
preg_match('|<img(.*) src="([^"]*)"[^>]*>|is', $row['short_story'], $pts);
$thumba_parts = pathinfo($pts[2]);
$titla = stripslashes($row['title']);
if($pts[2]){
$pictitle = stripslashes( $row['title'] );
$pic = $thumba_parts['dirname'].'/'.$thumba_parts['basename'];
$wide = str_replace('thumbs/', "", $pic);
if(file_exists($wide)) $preview = "<a href="$wide" onclick="return hs.expand(this)"><img src="$pic" width="66px"; style="max-width:600px;" alt="$pictitle" title="$pictitle"></a>";
else $preview = "<img src="$pic" width="66px"; style="max-width:600px;" alt="$pictitle" title="$pictitle">";
}
else $preview = "<img style="border: medium none;" src="{THEME}/images/nothumb.gif" width="66px" height="66px">";
$row['short_story'] = preg_replace("/[attachment=[[:digit:]]*]/si","",stripslashes($row['short_story']));
$row['short_story'] = preg_replace("/<!--*-->/si","",$row['short_story']);
$row['short_story'] = strip_tags($row['short_story']);
if( strlen( $row['short_story'] ) > 106 ) $row['short_story'] = substr( $row['short_story'], 0,120 ) . " ...";
$topnews .= '<table width="100%" border="0" style="border-bottom: 1px dotted #8D8D8D;">
<tr>
<td width="64" height=64" align="center" valign="top">'.$preview.'</td>
<td width="91%" valign="top" style="padding-left: 7px; padding-bottom: 7px;"><b><a href="'.$full_link.'" title="'.stripslashes( $row['title']).'">'.stripslashes( $row['title']).'</a></b><br>
'.stripslashes($row['short_story']).'</td>
</tr>
</table>';