DTcms新闻上一页,下一页代码
摘要:我也是DTcms的一位成员,开始也挺喜欢做DTcms网站的,他们的CMS上一页下一页的功能不是很健全
我在闲的时候就研究了一下写了上一页下一页的代码,今天我给大家分享一下
1,首先打开BasePage.cs文件插入以下代码:
/// <summary> /// 上一篇 /// </summary> protected string get_article_prelink(int channel_id, int id,int _category_id, string urlKey) { BLL.article bll = new BLL.article(); DataSet ds = bll.GetList(1, "is_lock=0 and Id>" + id + "and channel_id=" + channel_id + " and category_id="+_category_id+"", "id asc"); if (ds == null) return "< 无"; if (ds.Tables[0].Rows.Count <= 0) return "< 无"; return "<a href=\"" + linkurl(urlKey, ds.Tables[0].Rows[0]["id"]) + "\" title=\"" + ds.Tables[0].Rows[0]["title"] + "\" >< " + ds.Tables[0].Rows[0]["title"] + "</a>"; } /// <summary> /// 下一篇 /// </summary> protected string get_article_nextlink(int channel_id, int id, int _category_id, string urlKey) { BLL.article bll = new BLL.article(); DataSet ds = bll.GetList(1, "is_lock=0 and Id<" + id + "and channel_id=" + channel_id+" and category_id="+_category_id+"", "id desc"); if (ds == null) return "无 >"; if (ds.Tables[0].Rows.Count <= 0) return "无 >"; return "<a href=\"" + linkurl(urlKey, ds.Tables[0].Rows[0]["id"]) + "\" title=\"" + ds.Tables[0].Rows[0]["title"] + "\" >" + ds.Tables[0].Rows[0]["title"] + " ></a>"; }这样就可以了
2,调用上一页下一页
在新闻内页上面写上如下代码:
<%write get_article_prelink(model.channel_id, model.id, model.category_id, "article_show")%> <%write get_article_nextlink(model.channel_id, model.id, model.category_id, "article_show")%>这样就完成了,我这里只是写了新闻的上一页下一页,产品的上一页,下一页,要做稍微的改动,这个就要自己改了,其实是差不多的
如果有什么问题,可以直接留言给我,我会及时回复