ecshop的feed.xml.输出的全部都是商品,不输出文章的。但是我们频繁更新网站内容都是文章,相对来说文章收录也很好,那么如何把文章也加到这个总的feed.xml当中呢?
很简单,修改网站根目录下的feed.php文件,直接修改底部:
else
{
$in_cat = $cat > 0 ? ' AND ' . get_children($cat) : '';
$sql = 'SELECT c.cat_name, g.goods_id, g.goods_name, g.goods_brief, g.last_update ' .
'FROM ' . $ecs->table('category') . ' AS c, ' . $ecs->table('goods') . ' AS g ' .
'WHERE c.cat_id = g.cat_id AND g.is_delete = 0 AND g.is_alone_sale = 1 ' . $brd . $cat .
'ORDER BY g.last_update DESC';
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['goods_name']);
$link = $uri . $item_url . $separator ;
$desc = htmlspecialchars($row['goods_brief']);
$subject = htmlspecialchars($row['cat_name']);
$date = local_date('r', $row['last_update']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
}
$sql = 'SELECT article_id, title, author, add_time' .
' FROM ' .$GLOBALS['ecs']->table('article') .
' WHERE is_open = 1' ;
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('article', array('aid' => $row['article_id']), $row['title']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['title']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = '';
$subject = htmlspecialchars($row['author']);
$date = local_date('r', $row['add_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
}
$rss->outputRSS($ver);
}
就可以了,另外如何删除ecshop的feed.xml?from=rss,请看文章 //www.zuimoban.com/article-1420.html