Get all the subclass methods below the taxonomy:
static function Getmenutree ($arrCat, $parent _id = 0, $level = 0, $all =true) { static $arrTree;// Use static instead of global if (! $all) $arrTree = '; if (empty ($arrCat)) return FALSE; $level + +; if ($level = = 1) $arrTree [] = $parent _id; foreach ($arrCat as $key = + $value) { if ($value [' parent_cid '] = = $parent _id) { //$value [' Level ' ] = $level; $arrTree [] = $value [' CID ']; Unset ($arrCat [$key]); Unregisters the current node data, reducing the useless traversal self::getmenutree ($arrCat, $value [' CID '], $level); } } return $arrTree; }
The premise of using this method is to write the classification to the cache file, the cache file is written as follows:
Public Function ActionIndex2 () { $filepath = Yii::getpathofalias (' application '). ' /data/'; $arr = Array (); $db = Yii::app ()->db; $listinfo = $db->createcommand ("Select Name,cid,parent_cid,root_cid from Item_cat_info")->queryall (); foreach ($listinfo as $val) { $arr [$val [' cid ']] = Array (' cid ' + = $val [' CID '], ' name ' = + $val [' name '], ' Parent_cid ' = ' $val [' parent_cid '], ' root_cid ' and ' = ' $val [' root_cid ']); } $applist = "
"; File_put_contents ($filepath. ' itemcat.php ', $applist); }