Главная » 2011 » Май » 31 » topnews из определенной категории 3
03:05
topnews из определенной категории 3

Изменения:
Добавлена возможность работы с ЧПУ
Добавлена привьюшка картинки из короткой новости.
проверено на 8.2, должно работать и на остальных 8...
демо: http://donbass.name

в index.php перед
$config['http_home_url'] = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
Добавляем

if ( stristr( $tpl->copy_template, "{topnews" ) ) {

$tpl->copy_template = preg_replace( "#\\{topnews category=['"](.+?)['"]\\}#ies", "topnews_print('\\1')", $tpl->copy_template );

}
и в файле engine/modules/functions.php перед
function langdate($format, $stamp) {
добавляем функцию

function topnews_print ($custom_category){
global $db;
$custom_category = $db->safesql(str_replace(',', '|', $custom_category));

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

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

if (!$topnews) {

$this_month = date ('Y-m-d', time()-(3600*24*27));

$db->query("SELECT id, title, short_story, date, alt_name FROM " . PREFIX . "_post WHERE approve='1' AND category regexp '[[::]]' AND date >= '$this_month'AND date get_row()){

$row['date'] = strtotime($row['date']);

if (strlen($row['title']) > 55)
$title = substr ($row['title'], 0, 55)." ...";
else
$title = $row['title'];

$go_page = ($config['ajax']) ? "onclick="DlePage('newsid=".$row['id']."'); return false;" " : "";

if ($config['allow_alt_url'] == "yes")
$link = "";
else $preview = "
[img]$pic[/img]
";
}
else $preview = "
[img]/templates/Simple/images/nothumb.gif[/img]
";

$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,106 ) . " ... Читать далее »
";
$topnews .= '
'.$preview.'

'.stripslashes($row['short_story']).'

';
}

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

return $topnews;
}

Всё
Категория: Хаки | Просмотров: 367 | Добавил: ALL-DLE | Рейтинг: 0.0/0
Всего комментариев: 0
Имя *:
Email *:
Код *: