首页 > CMS建站 > PhpCMS > 正文

PHPCMS v9获取栏目的指定字段

2020-10-10 21:17:37
字体:
来源:转载
供稿:网友

官方有个强大的方法:$CATEGORYS

官方这个方法是很强大,在内容模块(modules)的各个class里面都有声明这个东西(没写到global里面),大家可以去看看.

以下是我写的获取方法get_param,效果,实现获取指定站点的指定栏目的指定字段内容,或者当前栏目的全部字段值,代码如下:

  1. function get_param($cid = '',$field = '',$siteid = ''){ 
  2.     emptyempty($cid) ? $catids = $catid : $catids = intval($cid); 
  3.     if (emptyempty($siteid)) $siteid = get_siteid(); 
  4.     $category = getcache('category_content_'.$siteid,'commons'); 
  5.     $cats = array(); 
  6.     foreach($category as $id=>$cat) { 
  7.         $cat['siteid'] == $siteid ? $cats[$id] = $cat : null ; 
  8.     }  //Cuoxin.com 
  9.  
  10.     return emptyempty($field) ? $cats[$catids] : $cats[$catids][$field]; 
  11. }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表