zoukankan      html  css  js  c++  java
  • 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 = 0;
        protected string prevlink = "";
        protected string nextlink = "";
        //资讯模型数据
        protected DataRow drInfo = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            //id为1的资讯模型
            int sysModelId = 1;
            //或者根据栏目id调用模型
            //int sysModelId = Channel.GetSysModelId(1);
            int.TryParse(Request["id"] as string, out artId);
            if (artId==0)
            {
                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[1]);
                string strLink=lenLink>30?Utils.CutLenString(arrPrevLink[1],28)+"...":arrPrevLink[1];
                prevlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrPrevLink[0], arrPrevLink[1], 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[1]);
                string strLink = lenLink > 30 ? Utils.CutLenString(arrNextLink[1], 28) + "..." : arrNextLink[1];
                nextlink = string.Format("<a href='/newsinfo.aspx?id={0}' title='{1}'>{2}</a>", arrNextLink[0], arrNextLink[1], strLink);
            }
    
        }
    
    
    }
  • 相关阅读:
    Emacs key bindings for vim users | Scarletsky
    Js对于数组去重提高效率一些心得
    http request GET 乱码分析
    ansible使用指北(二)
    Sed 实记 · laoless's Blog
    案例:文件下载器
    吴裕雄--天生自然python学习笔记:Python3 迭代器与生成器
    吴裕雄--天生自然HTML学习笔记:HTML
    吴裕雄--天生自然HTML学习笔记:HTML 速查列表
    吴裕雄--天生自然HTML学习笔记:HTML 统一资源定位器(Uniform Resource Locators)
  • 原文地址:https://www.cnblogs.com/dreamman/p/3373855.html
Copyright © 2011-2022 走看看