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);
            }
    
        }
    
    
    }
  • 相关阅读:
    Spring Security教程之自定义Spring Security默认的403页面
    Spring Security教程之Spring Security实现访问控制
    Spring Security的HTTP基本验证示例
    Maven3+Struts2.3.1.2整合的Hello World例子
    将Flex嵌入到Jsp页面实例-基于FlexModule插件
    Java I/O之FilenameFilter类列举出指定路径下某个扩展名的文件
    Java I/O之用FilenameFilter实现根据文件扩展名删除文件
    Flex与Java通信之HttpService方式
    Flex与Java通信之RemoteObject方式
    Flex之理解Flash中的事件机制
  • 原文地址:https://www.cnblogs.com/dreamman/p/3373855.html
Copyright © 2011-2022 走看看