示例#1
0
def tag(*, request, tag_id):
# 获取当前标签分类的名字
    tag = yield from Tag.findOne([tag_id])
    if tag is not None:
        # 获取博客分类和文章分类下的文章
        category_sql = ['%s %s %s' % (
            'select B.id,B.title,count(*) num from blog_category as A',
            'left join category as B on A.category_id = B.id where B.is_delete = 0',
            'group by A.category_id'
        )]
        blog_category = yield from select(category_sql, [])
        # 获取热门文章
        hot_blog_sql = ['select id,title,view_count from blogs order by view_count desc limit 10']
        hot_blog = yield from select(hot_blog_sql, [])
        return display('tag', {'blog_category': blog_category, 'hot_blog': hot_blog, 'tag': tag})
    else:
        return redirect('/404')