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);
            }
    
        }
    
    
    }
  • 相关阅读:
    ECharts
    JSON(及其在ajax前后端交互的过程)小识
    fullpage.js全屏滚动插件使用小结
    php json_encode数据格式化
    jQuery的DOM操作实例(3)——创建节点&&编写一个弹窗
    jQuery的DOM操作实例(2)——拖拽效果&&拓展插件
    jQuery的DOM操作实例(1)——选项卡&&Tab切换
    日常css技巧小结(2)-- inline-block带来的迷惑
    日常css技巧小结(1)--背景透明度改变对内容无影响
    浅析JavaScript事件流——冒泡
  • 原文地址:https://www.cnblogs.com/dreamman/p/3373855.html
Copyright © 2011-2022 走看看