Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Выкинь исходники?!Проблему решил. Полностью переписал код вывода rss
Ну и где код???
// формировать ленту RSS
function form_rss() {
global $CONFIG, $db, $tpl, $baseurl, $server, $lang;
$ND = new CNewsData_DB($this->table_prefix.'_news', 'id');
if ('' == $order_by) $order_by = $CONFIG['news_order_by'];
$rows = (int)$rows;
$start_row = ($start - 1) * $rows;
$category = (int)$category;
$ctg_str = ($category) ? 'category_id = '.$category.' AND' : '';
$temp = $ND->ListBy("", "date DESC", 0, -1);
$sql = "SELECT p.address FROM " . $this->table_prefix . "_pages_blocks pb INNER JOIN " . $this->table_prefix . "_pages p ON (p.id = pb.page_id) WHERE pb.action IN ('archive', 'alist', 'tlist', 'alist_archive', 'tlist_archive') AND pb.field_number = 0 LIMIT 1";
$db->query($sql);
if (!$db->nf()) {
$istrans = 0;
} else {
$istrans = 1;
}
while ($db->next_record()) {
$link = $db->f("address");
}
if (!file_exists(RP."rss") || !is_dir(RP."rss")) {
mkdir(RP."rss");
}
$rss_filename = RP."rss/".$server.$lang.".xml";
if ($f = fopen($rss_filename, "w")) {
fwrite($f, '<?xml version="1.0" encoding="windows-1251"?>
');
fwrite($f, '<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
');
fwrite($f, '<rss version="2.0" xml:base="'.$CONFIG["web_address"].'">
');
fwrite($f, '<channel>
');
fwrite($f, '<title>Новости сайта http://'.$CONFIG["sitename"].'</title>
');
fwrite($f, '<link>'.$CONFIG["web_address"].'</link>
');
fwrite($f, '<description />
');
fwrite($f, '<language>'.$lang.'</language>
');
// выводим поля таблицы pached by Rokkis
$sql_items = "SELECT * FROM " . $this->table_prefix . "_news WHERE active = 1 order by date DESC LIMIT 0,20";
$result = mysql_query($sql_items)
or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
while ( $row = mysql_fetch_array($result) ) {
$ttl = $row["title"] ;
$idd = $row["id"] ;
$desc = $row["announce"] ;
$news_date = $row["date"] ;
$status = $row["status"] ;
// вывод списка
$news_link = "http://".$_SERVER["HTTP_HOST"]."/" . $link . "?action=show&id=".$idd;
fwrite($f, '<item>
');
fwrite($f, ' <title>'.$ttl.'</title>
');
if($istrans == 1) {
fwrite($f, ' <link>'.$news_link.'</link>
');
}
fwrite($f, ' <description>'.nl2br($desc).'</description>
');
fwrite($f, ' <pubDate>'.$news_date.'</pubDate>
');
fwrite($f, '</item>
');
}
}
fwrite($f, '</channel>
');
fwrite($f, '</rss>
');
fclose($f);
return TRUE;
}
return FALSE;
}
Функция вывода rss целиком бабахнуть в class.News.php
PHP:// формировать ленту RSS function form_rss() { global $CONFIG, $db, $tpl, $baseurl, $server, $lang; $ND = new CNewsData_DB($this->table_prefix.'_news', 'id'); if ('' == $order_by) $order_by = $CONFIG['news_order_by']; $rows = (int)$rows; $start_row = ($start - 1) * $rows; $category = (int)$category; $ctg_str = ($category) ? 'category_id = '.$category.' AND' : ''; $temp = $ND->ListBy("", "date DESC", 0, -1); $sql = "SELECT p.address FROM " . $this->table_prefix . "_pages_blocks pb INNER JOIN " . $this->table_prefix . "_pages p ON (p.id = pb.page_id) WHERE pb.action IN ('archive', 'alist', 'tlist', 'alist_archive', 'tlist_archive') AND pb.field_number = 0 LIMIT 1"; $db->query($sql); if (!$db->nf()) { $istrans = 0; } else { $istrans = 1; } while ($db->next_record()) { $link = $db->f("address"); } if (!file_exists(RP."rss") || !is_dir(RP."rss")) { mkdir(RP."rss"); } $rss_filename = RP."rss/".$server.$lang.".xml"; if ($f = fopen($rss_filename, "w")) { fwrite($f, '<?xml version="1.0" encoding="windows-1251"?> '); fwrite($f, '<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]> '); fwrite($f, '<rss version="2.0" xml:base="'.$CONFIG["web_address"].'"> '); fwrite($f, '<channel> '); fwrite($f, '<title>Новости сайта http://'.$CONFIG["sitename"].'</title> '); fwrite($f, '<link>'.$CONFIG["web_address"].'</link> '); fwrite($f, '<description /> '); fwrite($f, '<language>'.$lang.'</language> '); // выводим поля таблицы pached by Rokkis $sql_items = "SELECT * FROM " . $this->table_prefix . "_news WHERE active = 1 order by date DESC LIMIT 0,20"; $result = mysql_query($sql_items) or die ("Can't execute query."); $num = mysql_numrows($result); if ($num != 0) { while ( $row = mysql_fetch_array($result) ) { $ttl = $row["title"] ; $idd = $row["id"] ; $desc = $row["announce"] ; $news_date = $row["date"] ; $status = $row["status"] ; // вывод списка $news_link = "http://".$_SERVER["HTTP_HOST"]."/" . $link . "?action=show&id=".$idd; fwrite($f, '<item> '); fwrite($f, ' <title>'.$ttl.'</title> '); if($istrans == 1) { fwrite($f, ' <link>'.$news_link.'</link> '); } fwrite($f, ' <description>'.nl2br($desc).'</description> '); fwrite($f, ' <pubDate>'.$news_date.'</pubDate> '); fwrite($f, '</item> '); } } fwrite($f, '</channel> '); fwrite($f, '</rss> '); fclose($f); return TRUE; } return FALSE; }
Добавлено через 3 минуты
код выводит 20 последних записей новостей.
если надо меньше или больше, например 10 - ставим LIMIT 0,10
или можно прикрутить чтоб ставилось из админки. Мне было влом, воткнул фиксированное значение
89 if ($CONFIG["news_form_rss"] == "on") {
90 $news->form_rss();
91 }
91 header('Location: '.$baseurl.'&action=shownews&category='.$request_category);
93 } else {
function db_loadList( $sql, $maxrows=NULL ) {
if (!($cur = db_exec( $sql ))) {;
echo db_error();
return false;
}
$list = array();
$cnt = 0;
while ($hash = db_fetch_assoc( $cur )) {
$list[] = $hash;
if( $maxrows && $maxrows == $cnt++ ) {
break;
}
}
db_free_result( $cur );
return $list;
}