网站建设 郑州网站建设 网站制作 网页设计 网站设计 郑州建网站 - 爱易在线

网站地图 | 网站Tags标签 | RSS订阅 | 加入收藏
您的位置:网站首页 > 博客笔记 > 技术交流 > 正文 技术交流相关信息

iNethinkCMS增加获取所有子栏目ID标签

作者:郑州网站建设 2014/12/24 19:41:21 点击: 来源:

在建站过程中,我们经常要根据父栏目调用所有子栏目下的文章,iNethinkCMS数据库建立的有所有子栏目,但是没有对应的标签去解析。所以,我添加了一个标签。[sys:GetChildIDs(1)]

 

WebUI_Template.cs中增加代码:

/// <summary>  
        /// 解析指定栏目下的ChildIDs  
        /// </summary>  
        /// <returns></returns>  
        public string Parser_GetChildIDs()  
        {  
            iNethinkCMS.Model.Model_iNethinkCMS_Channel channel = new Model.Model_iNethinkCMS_Channel();  
            iNethinkCMS.BLL.BLL_iNethinkCMS_Channel channelBll = new BLL.BLL_iNethinkCMS_Channel();  
    
            string ChildIDs = "0";  
            Regex regex = new Regex(@"\[sys:GetChildIDs\((\d+)\)\]", RegexOptions.IgnoreCase);  
            MatchCollection matchCollection = regex.Matches(vContent);  
            foreach (Match m in matchCollection)  
            {  
                int Cid = int.Parse(m.Groups[1].Value);  
                if (Cid<1)  
                {  
                    Cid = 1;  
                }  
                channel = channelBll.GetModel(Cid);  
                ChildIDs = channel.ChildIDs;  
                vContent = vContent.Replace(m.Value, ChildIDs);  
            }  
            return vContent;  
        }

在需要添加获取所有子栏目ID的后台页面增加代码如下,以首页为例在Fun_GetIndexContent方法中增加 wt.Parser_GetChildIDs();

private string Fun_GetIndexContent(int byPage) 
       { 
           string vTemplateUrl = (siteConfig.IndexTemplateName); 
           WebUI_Template wt = new WebUI_Template(); 
           wt.Load_Template(vTemplateUrl); 
           wt.vPage = byPage; 
 
           wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:title}"), siteConfig.WebName, RegexOptions.IgnoreCase); 
           wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:seotitle}"), seoConfig.SeoTitle, RegexOptions.IgnoreCase); 
           wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:keywords}"), seoConfig.IndexKeywords, RegexOptions.IgnoreCase); 
           wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:description}"), seoConfig.IndexDescription, RegexOptions.IgnoreCase); 
           wt.vContent = Regex.Replace(wt.vContent, Regex.Escape("{sys:sitepath}"), "<a href=\"/\">首页</a>", RegexOptions.IgnoreCase); 
           wt.Parser_GetChildIDs();//此处增加的解析获取所有子栏目ID的标签 
           wt.Parser_MyTag(); 
           wt.Parser_List(); 
           wt.Parser_Page(); 
           wt.Parser_IF(); 
           return wt.vContent; 
       }

首页index.html模板中读取父栏目ID为1的所有子栏目的文章示例:

 

<!--list:{$Sql=Select Top 10 * From iNethinkCMS_Content Where [Display]=1 and Cid in([sys:GetChildIDs(1)]) Order by Id Desc }-->

 

 

 

 

Tag:
分享到:

上一篇:Jquery+css+图片美化radio

下一篇:C#仿php函数hash("sha256", $str)

技术交流推荐阅读

用户评论

最新博文

热门排行

推荐信息

关于爱之易| 付款方式| 联系我们| 网站地图| 网站Tags标签 | RSS订阅