Правка Модуля (Lastnews) в DLE

Gaborik
На сайте с 27.03.2010
Offline
80
1928

Вообщем установил данный модуль. Модуль выдаёт сылки ввиде (ЧПУ третьего вида)

вот примерно так: http://site.ru/2008/04/02/имя новости.html

Как сделать чтобы новости выводились в (ЧПУ первого вида)

так:

http://site.ru/id-имя новости.html

Мне кажется нужно править тут:

if ($config['allow_alt_url'] == "yes")
$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">\\1</a>");
else
$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">\\1</a>");

Вот весь код модуля:

<?php
/*
=====================================================
Данный код защищен авторскими правами
=====================================================
Файл: lastnews.php
-----------------------------------------------------
Назначение: Последние новости v 2.1
=====================================================
*/
if(!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
/*===========================================
НАСТРОЙКИ
=============================================*/
$lastnewsconf['news'] = 200; // Длина новости
$lastnewsconf['link'] = 30; // Обрезание титла новостей
$lastnewsconf['limit'] = 10; // Количество новостей
$lastnewsconf['hide_html'] = true;// Уберать все теги из текста новости (true - да, false - нет)
$lastnewsconf['only_hide_main'] = false;// Показывать только новости не опубликованые на главной (true - да, false - нет)
$lastnewsconf['category'] = '1,2,3,4,5'; // Показывать категории, перечислите ID категорий через запятую без пробелов. Если нужно показвать все оставте поле пустым

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

if (!$lastnews) {
//include(ENGINE_DIR.'/inc/parse.class.php');
//$parse = new ParseFilter(Array(), Array());

if ($lastnewsconf['only_hide_main'])
$ln_allow_main = 'and allow_main=0';
else
$ln_allow_main = '';

if ($lastnewsconf['category'])
$ln_category = 'and category = '. str_replace(',',' or ', $lastnewsconf['category']);
else
$ln_category = '';

$tpl->load_template('lastnews.tpl');
$db->query("SELECT id, title, short_story , date, alt_name FROM ". PREFIX . "_post WHERE approve='1' $ln_allow_main $ln_category ORDER BY date DESC LIMIT 0,{$lastnewsconf['limit']}");

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

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

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

//$row['short_story'] = preg_replace("/\[attachment=[[:digit:]]*\]/si","",stripslashes($parse->BB_Parse($parse->process($row['short_story']))));
$row['short_story'] = preg_replace("/\[attachment=[[:digit:]]*\]/si","",stripslashes($row['short_story']));
$row['short_story'] = preg_replace("/<!--*-->/si","",$row['short_story']);
if($lastnewsconf['hide_html'])$row['short_story'] = strip_tags($row['short_story']);


if (strlen($row['short_story']) > $lastnewsconf['news'])
$short_story = substr ($row['short_story'], 0, $lastnewsconf['news'])." ...";
else
$short_story = $row['short_story'];

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

if ($config['allow_alt_url'] == "yes")
$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">\\1</a>");
else
$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">\\1</a>");


$tpl->set('{title}', stripslashes($title));
$tpl->set('{short_news}', $short_story);

$tpl->compile('lastnews');

}
$lastnews = $tpl->result['lastnews'];
}

?>
Живу одним днём...
sashka_
На сайте с 27.01.2010
Offline
103
#1

меняем


$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">\\1</a>"

на


$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"".$config['http_home_url'].$row['id']."-".$row['alt_name'].".html\">\\1</a>"

забыл =(

Знаю PHP, JS, jQuery. Помощь для вашего сайта. (/ru/forum/840509).
Gaborik
На сайте с 27.03.2010
Offline
80
#2

Спасиб помогло...

Немного подругому ток...

$tpl->set_block("'\[full-link\](.*?)\[/full-link\]'si", "<a {$go_page}href=\"".$config['http_home_url'].$row['id']."-".$row['alt_name'].".html\">\\1</a>

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