<?php
namespace frontend\widgets;

use Yii;
use yii\base\Widget;
use common\components\CHelper;
use yii\helpers\Html;
use common\models\ArticleCategory;
use common\models\ProductCategory;
use common\models\About;
class NavWidget extends Widget
{
    
    public function init()
    {
        parent::init();
    }
    
    public function run()
    {
        $article_category = ArticleCategory::getCache();
        $product_category = ProductCategory::getCache();
        $about_list = About::getCache();
    	// $data = Article::find()->andWhere(['cid'=>2,'display'=>1]);
     //    $list = $data->asArray()->orderBy('click desc,updatetime desc,id desc')->limit($this->limit)->all();
     //    $list = $this->_format_list($list);
    	return $this->render('/widgets/nav',[
    		'article_category'=>$article_category,
            'product_category'=>$product_category,
            'about_list'=>$about_list,
    	]);
    }
    // private function _format_list($list){
    //     foreach ($list as $key => $value) {
    //     	$list[$key]['title'] = Html::encode(CHelper::cutStr($value['title'],15));
    //         $list[$key]['url'] = Yii::$app->urlManager->createUrl(['news/detail','id'=>$value['id']]);
    //     }
    //     return $list;
    // }
}