getPk(); $tpl = ""; switch($row['typedata']){ case 'article'; $tpl = "list_article"; break; case 'images'; $tpl = "list_images"; break; case 'page'; $tpl = "page"; break; default : $tpl = "page"; break; } $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk], 'tpl'=>$tpl]); }); } public function getTypedataList() { return ['article' => __('Typedata article'), 'images' => __('Typedata images'), 'page' => __('Typedata page')]; } public function getStatusList() { return ['normal' => __('Normal'), 'hidden' => __('Hidden')]; } public function getTypedataTextAttr($value, $data) { $value = $value ? $value : (isset($data['typedata']) ? $data['typedata'] : ''); $list = $this->getTypedataList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public static function getTree(){ $list = self::where(['status'=>'normal'])->order('weigh desc')->select(); $tree = Tree::instance()->init($list, 'pid'); $list = $tree->getTreeList($tree->getTreeArray(0), 'title'); return $list; } }