PlugNT CMS v4.6.3 调用文章上一页和下一页及点击数加1

时间:2023-03-09 22:37:15
PlugNT CMS v4.6.3  调用文章上一页和下一页及点击数加1
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; using PlugNT.Common;
using PlugNT.Cms.Custom;
using PlugNT.Cms.Model;
using PlugNT.Cms.BLL;
using PlugNT.Cms.Page;
using PlugNT.Cms.Utility; public partial class _Newsinfo : SitePager
{ protected int artId = ;
protected string prevlink = "";
protected string nextlink = "";
//资讯模型数据
protected DataRow drInfo = null;
protected void Page_Load(object sender, EventArgs e)
{
//id为1的资讯模型
int sysModelId = ;
//或者根据栏目id调用模型
//int sysModelId = Channel.GetSysModelId(1);
int.TryParse(Request["id"] as string, out artId);
if (artId==)
{
PageHelper.ShowError(this.Context, "参数错误!");
return;
} Article bllArticle = new Article();
drInfo = bllArticle.GetDataRow(sysModelId, artId);
if (drInfo == null)
{
PageHelper.ShowError(this.Context, "查看的内容不存在!");
return;
} //点击数加1
ArticleInfo info = new ArticleInfo();
info.id = artId;
info.SetExtField("hits", Type_Field.integerType, "hits+1");
bllArticle.UpdateData(sysModelId, info); //上一页
string[] arrPrevLink = Article.GetArray(sysModelId, "id,title", " and id<" + artId + " and [channel_id]=" + drInfo["channel_id"].ToString() + " order by id desc");
if (arrPrevLink == null)
{
prevlink = "没有了";
}
else
{
//获取真实字符数
int lenLink=Utils.GetStringLength(arrPrevLink[]);
string strLink=lenLink>?Utils.CutLenString(arrPrevLink[],)+"...":arrPrevLink[];
prevlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrPrevLink[], arrPrevLink[], strLink);
} //下一页
string[] arrNextLink = Article.GetArray(sysModelId, "id,title", " and id>" + artId + " and [channel_id]=" + drInfo["channel_id"].ToString() + " order by id asc");
if (arrNextLink == null)
{
nextlink = "没有了";
}
else
{
//获取真实字符数
int lenLink = Utils.GetStringLength(arrNextLink[]);
string strLink = lenLink > ? Utils.CutLenString(arrNextLink[], ) + "..." : arrNextLink[];
nextlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrNextLink[], arrNextLink[], strLink);
} } }