zoukankan      html  css  js  c++  java
  • dedecms获取指定栏目下的文章数量

    如何统计dedecms获取指定栏目下的文章数量。

    修改文件:

    /include/helpers/channelunit.helper.php
    

    在文件最后添加函数:

    /**
     * 获取指定栏目下面的文章数量
     * 优植网 https://www.3uzw.com
     * @param     string  $id  栏目id
     * @param     string  $addthis  是否包含子栏目
     * @return    string
    */
    if ( ! function_exists('getTypeArcLength')) {
    	function getTypeArcLength($id,$addson=true) {
    		global $dsql;
    		if($addson) {		
    			$types = GetSonIds($id);				
    			$sql = "SELECT count(id) as len FROM 前缀_arctiny where typeid IN ($types)";
    		} else {
    			$sql = "SELECT count(id) as len FROM 前缀_arctiny where typeid = $id";
    		}
    		$arclen = $dsql->GetOne($sql);
    		return $arclen['len'];
    	}
    }
    

    模板底层调用代码:

    {dede:field.id function="getTypeArcLength(@me,false)"/}
    

    或者为:

    {dede:type typeid='24'}
    [field:id function="getTypeArcLength(@me,false)"/]
    {/dede:type}
    

      

  • 相关阅读:
    Vue
    Vue
    Vue
    Vue
    Vue
    Vue
    Vue
    Vue
    Vue
    建立索引该如何选取字段
  • 原文地址:https://www.cnblogs.com/feixiablog/p/15646053.html
Copyright © 2011-2022 走看看