NetCMS修改之四:扩展轮换幻灯片属性(NorFilt),具有导读显示

    NetCMS有两种幻灯片显示方式:Flash幻灯片和轮换幻灯片。Flash幻灯片是通过将图片新闻中的图片合成Flash后再在页面上显示。轮换幻灯片则是使用脚本进行控制(准确地说,是使用VBScript)。

    其实,这两种显示形式差不多,只不过Flash幻灯片是通过Flash实现图片的过渡效果,而轮换幻灯片是利用IE提供的Filter属性实现图片过渡效果的。

    鉴于轮换幻灯片是通过脚本控制Img标记的Src属性及Div标记的Innerhtml属性来实现图片切换和标题切换的。因此就想实现在图片右边显示新闻导读,效果如下:

NetCMS修改之四:扩展轮换幻灯片属性(NorFilt),具有导读显示_第1张图片

    轮换幻灯片的标签定义如下:

    [NT:Loop,NT:SiteID=0,NT:LabelType=NorFilt,NT:Number=10,NT:ClassID=0,NT:isSub=true,NT:TitleNumer=25,NT:WCSS=css,NT:ShowTitle=true,
NT:FlashSize=参数1|参数2,NT:Target=_blank][/NT:Loop]

    各参数的意义请参看NetCMS官方网站对此标签的说明(http://www.aspxcms.com/help/label/start.html#NorFilt)。

    现给其增加以下参数:

    NT:HashNaviContent:true或flase,是否显示导读。如果不显示导读,则与原来效果一致。

    NT:NaviContentWidth:导读部分的宽度(px)

    NT:NaviTitleCSS:导读部分标题的CSS样式

    NT:NaviCntCSS:导读部分内容的CSS样式

 

    对NorFilt标签的处理,是由NetCMS.Publish.LabelMass类中的Analyse_NorFilt()方法(NetCMS.Publish/Label/LabelMass_Method4.cs)进行处理的。现将改动后的Analyse_NorFilt()方法提供如下,增加或修改部分均做了注释:

        ///


        /// 轮换幻灯片
        ///

        ///
        public string Analyse_NorFilt()
        {
            string str_NorFilt = "";
            string str_ClassID = this.GetParamValue("NT:ClassID");
            string str_isSub = this.GetParamValue("NT:isSub");
            string str_TitleNumer = this.GetParamValue("NT:TitleNumer");
            string str_WCSS = this.GetParamValue("NT:WCSS");
            string str_ShowTitle = this.GetParamValue("NT:ShowTitle");
            string str_FlashSize = this.GetParamValue("NT:FlashSize");
            string str_Target = this.GetParamValue("NT:Target");

            // 以下由Whitewin于2009-4-21添加
            // 给NorFilt幻灯新闻增加右部的导读。
            string str_HashNaviContent = this.GetParamValue("NT:HashNaviContent");//获取导读标记
            string str_NaviContentWidth = this.GetParamValue("NT:NaviContentWidth"); //获取导读部分宽度
            string str_NaviTitleCSS = this.GetParamValue("NT:NaviTitleCSS");   //获取导读部分标题样式
            string str_NaviCntCSS = this.GetParamValue("NT:NaviCntCSS");   // 获取导读部分内容文本样式
            // --------------------------------------------------------------------------------

            string SqlCondition = " Where [isRecyle]=0 And [isLock]=0 And [SiteID]='" + this.Param_SiteID + "' And [NewsType]=1 And SubString([NewsProperty],7,1)='1'";
            string SqlOrderBy = " Order By [CreatTime] Desc";

            #region 对栏目进行判断
            DataTable dt = null;
            string Sql = string.Empty;
            if (str_ClassID == null || str_ClassID == "-1")
            {
                if (this._TemplateType == TempType.Class)
                {
                    if (str_isSub == "true")
                        SqlCondition += " And [ClassID] In (" + getChildClassID(this.Param_CurrentClassID) + ")";
                    Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News] " + SqlCondition + " And ClassID='" + this.Param_CurrentClassID + "' " + SqlOrderBy;
                }
                else
                {
                    Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News] " + SqlCondition + SqlOrderBy;
                }
            }
            else if (str_ClassID == "0")
            {
                Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News]" + SqlCondition + SqlOrderBy;
            }
            else
            {
                if (str_isSub == "true")
                    SqlCondition += " And [ClassID] In (" + getChildClassID(str_ClassID) + ")";
                Sql = "select top " + Param_Loop + " * from [" + DBConfig.TableNamePrefix + "News]" + SqlCondition + SqlOrderBy;
            }
            dt = CommonData.DalPublish.ExecuteSql(Sql);
            #endregion 对栏目进行判断

            if (dt != null)
            {
                if (dt.Rows.Count < 2)
                {
                    str_NorFilt = "至少需要两条幻灯新闻才能正确显示幻灯效果";
                    return str_NorFilt;
                }
                string str_FlashWidth = " width='200'";
                string str_FlashHeight = " height='100'";

                if (str_FlashSize != null)
                {
                    string[] arr_FlashSize = str_FlashSize.Split('|');
                    str_FlashWidth = " width='" + arr_FlashSize[0].ToString() + "'";
                    str_FlashHeight = " height='" + arr_FlashSize[1].ToString() + "'";
                }
                if (str_WCSS != null)
                    str_WCSS = " class='" + str_WCSS + "'";
                if (str_Target != null)
                    str_Target = " target='" + str_Target + "'";

                string str_Imgstr = "";     // 图片链接
                string str_Linkstr = "";    // 新闻链接
                string str_Txtstr = "";     // 标题链接
                string str_FirstTxt = "";   // 第一次显示时的新闻标题

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                string str_NaviCnt = "";    // 导读新闻内容
                string str_FirstNaviCnt = "";  // 第一次显示时的导读新闻内容
                string str_NaviTitle = "";  // 导读新闻标题
                string str_FirstNaviTitle = ""; // 第一次显示时的导读新闻标题
                if (str_NaviTitleCSS != null)
                    str_NaviTitleCSS = " class='" + str_NaviTitleCSS + "'";
                if (str_NaviCntCSS !=null)
                    str_NaviCntCSS = " class='" + str_NaviCntCSS + "'";
                // ------------------------------------------------------------

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    PubClassInfo ci = CommonData.GetClassById(dt.Rows[i]["ClassID"].ToString());

                    string str_PicUrl = RelpacePicPath(dt.Rows[i]["PicURL"].ToString());
                    string str_Link = getNewsURL(dt.Rows[i]["isDelPoint"].ToString(), dt.Rows[i]["NewsID"].ToString(), dt.Rows[i]["SavePath"].ToString(), ci.SavePath + "/" + ci.SaveClassframe, dt.Rows[i]["FileName"].ToString(), dt.Rows[i]["FileEXName"].ToString());
                    string str_Txt = dt.Rows[i]["NewsTitle"].ToString();
                    string str_NaviCntTxt = dt.Rows[i]["NaviContent"].ToString();

                    // 以下由Whitewin于2009-4-21添加
                    // 给NorFilt幻灯新闻增加右部的导读。
                    // 获取完整新闻标题,用作导读部分标题的提示
                    string uTitle = str_Txt;
                    // -----------------------------------------

                    if (str_TitleNumer != null)
                        str_Txt = NetCMS.Common.Input.GetSubString(str_Txt, Convert.ToInt32(str_TitleNumer));

                    if (str_PicUrl != "" && str_PicUrl != null)
                    {
                        if (str_Imgstr == "")
                        {
                            str_Imgstr += str_PicUrl;
                            str_Linkstr += str_Link;
                            str_Txtstr += "" + str_Txt + "";
                            str_FirstTxt = str_Txtstr;
                            // 以下由Whitewin于2009-4-21添加
                            // 给NorFilt幻灯新闻增加右部的导读。
                            // 处理导读部分新闻标题
                            str_NaviTitle = "" + str_Txt + "";
                            str_FirstNaviTitle = str_NaviTitle;
                            str_NaviCnt = str_NaviCntTxt + "" + "[详情]" + "";   //处理导读新闻内容
                            str_FirstNaviCnt = str_NaviCnt;
                            // --------------------------------------------------------------------------------

                        }
                        else
                        {
                            str_Imgstr += "," + str_PicUrl;
                            str_Linkstr += "," + str_Link;
                            str_Txtstr += "," + str_Txt + "";
                            // 以下由Whitewin于2009-4-21添加
                            // 给NorFilt幻灯新闻增加右部的导读。
                            // 处理导读部分新闻标题
                            str_NaviTitle += "," + str_Txt + "";
                            str_NaviCnt += "<#NaviContent>" + str_NaviCntTxt + "" + "[详情]" + "";    //处理导读新闻内容
                            // --------------------------------------------------------------------------------
                        }
                    }
                }
                str_NorFilt += "" + newLine;
                str_NorFilt += "

" + newLine;
                str_NorFilt += "" + newLine;
                str_NorFilt += "" + newLine;
                str_NorFilt += "" + newLine;

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 将原有图片部分包含在表格中
                if (str_HashNaviContent == "true")
                {
                    str_NorFilt += "

" + newLine;
                }
                // --------------------------------------------------------------------------------

                str_NorFilt += "

对不起,图片浏览功能需脚本支持,但您的浏览器已经设置了禁止脚本运行。请您在浏览器设置中调整有关安全选项。
" + newLine;
                    str_NorFilt += "
" + newLine;
                }
                // --------------------------------------------------------------------------------

                str_NorFilt += "

" + newLine;
                if (str_ShowTitle == "true")
                {
                    str_NorFilt += "" + newLine;
                }

                // 以下由Whitewin于2009-4-21添加
                // 给NorFilt幻灯新闻增加右部的导读。
                // 添加导读部分
                if (str_HashNaviContent == "true")
                {
                    str_NorFilt += "

" + newLine;
                str_NorFilt += "
" + newLine;
                    str_NorFilt += "
" + str_FirstTxt + "
" + newLine;
                    str_NorFilt += "
" + newLine;
                    str_NorFilt += "" + newLine;
                    str_NorFilt += "";
                    str_NorFilt += "
" + str_FirstNaviTitle + "
 
" + str_FirstNaviCnt + "
" + newLine;
                str_NorFilt += "" + newLine;

                dt.Clear(); dt.Dispose();
            }
            else
            {
                str_NorFilt = "没有幻灯片";
            }
            return str_NorFilt;
        }

    对NetCMS.Publish项目和NetCMS.Web重新生成后,将NetCMS.Web/Bin文件夹下的NetCMS.Publish.Dll文件复制到Web服务器对应的Bin文件夹下,替换掉原来的NetCMS.Publish.Dll文件即可。

你可能感兴趣的:(NetCMS)