Commit 3d620c673fcf30eca0d84eb159397456bc9cae19
1 parent
f7089e23
15.02.16
Showing
4 changed files
with
48 additions
and
3 deletions
Show diff stats
frontend/config/main.php
@@ -64,6 +64,7 @@ return [ | @@ -64,6 +64,7 @@ return [ | ||
64 | 'showScriptName' => false, | 64 | 'showScriptName' => false, |
65 | 'rules' => [ | 65 | 'rules' => [ |
66 | 'landing/<view:[\w-]+>' => 'landing/view', | 66 | 'landing/<view:[\w-]+>' => 'landing/view', |
67 | + 'performer/portfolio/<performer_id:[\w-]+>/<filter:[\d]+>' => 'performer/portfolio-filter', | ||
67 | 'performer/blog-view/<performer_id:[\w-]+>/<link:[\w-]+>' => 'performer/blog-view', | 68 | 'performer/blog-view/<performer_id:[\w-]+>/<link:[\w-]+>' => 'performer/blog-view', |
68 | 'performer/<action>/<performer_id:[\w-]+>' => 'performer/<action>', | 69 | 'performer/<action>/<performer_id:[\w-]+>' => 'performer/<action>', |
69 | 'company/blog-view/<company_id:[\w-]+>/<link:[\w-]+>' => 'company/blog-view', | 70 | 'company/blog-view/<company_id:[\w-]+>/<link:[\w-]+>' => 'company/blog-view', |
frontend/controllers/PerformerController.php
@@ -103,6 +103,41 @@ class PerformerController extends Controller | @@ -103,6 +103,41 @@ class PerformerController extends Controller | ||
103 | 103 | ||
104 | } | 104 | } |
105 | 105 | ||
106 | + public function actionPortfolioFilter($performer_id, $filter){ | ||
107 | + $user = User::findOne($performer_id); | ||
108 | + | ||
109 | + if(!$user instanceof User){ | ||
110 | + throw new BadRequestHttpException('Пользователь не найден'); | ||
111 | + } | ||
112 | + $portfolios = ArrayHelper::getColumn($user->portfolios,'portfolio_id'); | ||
113 | + | ||
114 | + | ||
115 | + $filters = PortfolioSpecialization::find()->select(["specialization_id","COUNT('specialization_id') AS count"]) | ||
116 | + ->where(["portfolio_id"=>$portfolios ])->groupBy("specialization_id")->all(); | ||
117 | + | ||
118 | + | ||
119 | + $filter_result = PortfolioSpecialization::find() | ||
120 | + ->where(['specialization_id'=>$filter, | ||
121 | + 'portfolio_id'=>$portfolios | ||
122 | + ])->all(); | ||
123 | + | ||
124 | + | ||
125 | + $portfolio = new ArrayDataProvider([ | ||
126 | + 'allModels' => Portfolio::find()->where(['portfolio_id'=>ArrayHelper::getColumn($filter_result,'portfolio_id')])->all(), | ||
127 | + 'pagination' => [ | ||
128 | + 'pageSize' => 9, | ||
129 | + ], | ||
130 | + ]); | ||
131 | + | ||
132 | + return $this->render('portfolio',[ | ||
133 | + 'user' => $user, | ||
134 | + 'filters' => $filters, | ||
135 | + 'portfolio' => $portfolio, | ||
136 | + 'filter_id' => $filter, | ||
137 | + 'count' => count($user->portfolios) | ||
138 | + ]); | ||
139 | + } | ||
140 | + | ||
106 | public function actionBlogList($performer_id) | 141 | public function actionBlogList($performer_id) |
107 | { | 142 | { |
108 | $user = User::findOne($performer_id); | 143 | $user = User::findOne($performer_id); |
frontend/views/performer/portfolio.php
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | use yii\helpers\ArrayHelper; | 3 | use yii\helpers\ArrayHelper; |
4 | use \yii\helpers\Html; | 4 | use \yii\helpers\Html; |
5 | +use yii\helpers\Url; | ||
5 | use yii\widgets\ListView; | 6 | use yii\widgets\ListView; |
6 | 7 | ||
7 | 8 | ||
@@ -12,16 +13,22 @@ $this->params['user'] = $user; | @@ -12,16 +13,22 @@ $this->params['user'] = $user; | ||
12 | $this->title = 'My Yii Application'; | 13 | $this->title = 'My Yii Application'; |
13 | ?> | 14 | ?> |
14 | <div class="performer-vacancy-vacant-title-reclam-wr style"> | 15 | <div class="performer-vacancy-vacant-title-reclam-wr style"> |
16 | + | ||
15 | <div class="portfolio-project-wr style"> | 17 | <div class="portfolio-project-wr style"> |
16 | <div class="workplace-title style"><p>Проектов: <?= $portfolio->totalCount ?></p></div> | 18 | <div class="workplace-title style"><p>Проектов: <?= $portfolio->totalCount ?></p></div> |
17 | <div class="portfolio-project-tags style"> | 19 | <div class="portfolio-project-tags style"> |
18 | - <a href="#" class="active-tag">Все (<?= $portfolio->totalCount ?>)</a> | 20 | + <?= Html::a("Все ({$count})", ['performer/portfolio', 'performer_id'=> $user->id], |
21 | + ['class'=> !isset($filter_id) || empty($filter_id) ? "active-tag" : ""]);?> | ||
22 | + <a href="#" class="active-tag"></a> | ||
19 | <?php foreach($filters as $filter): ?> | 23 | <?php foreach($filters as $filter): ?> |
20 | - <a href="#"><?= $filter->specialization->specialization_name ?> (<?= $filter->count ?>)</a> | 24 | + <?= Html::a("{$filter->specialization->specialization_name} ({$filter->count})", |
25 | + Url::toRoute(['performer/portfolio-filter', 'performer_id'=> $user->id, 'filter' => $filter->specialization->specialization_id]), | ||
26 | + ['class'=> isset($filter_id) && $filter->specialization->specialization_id == $filter_id ? "active-tag" : ""]);?> | ||
21 | <?php endforeach; ?> | 27 | <?php endforeach; ?> |
22 | 28 | ||
23 | </div> | 29 | </div> |
24 | </div> | 30 | </div> |
31 | + | ||
25 | <div class="style"> | 32 | <div class="style"> |
26 | <div class="portfolio-project-blocks-wrapper"> | 33 | <div class="portfolio-project-blocks-wrapper"> |
27 | <?= | 34 | <?= |
@@ -34,4 +41,5 @@ $this->title = 'My Yii Application'; | @@ -34,4 +41,5 @@ $this->title = 'My Yii Application'; | ||
34 | 41 | ||
35 | </div> | 42 | </div> |
36 | </div> | 43 | </div> |
44 | + | ||
37 | </div> | 45 | </div> |
38 | \ No newline at end of file | 46 | \ No newline at end of file |
frontend/views/performer/portfolio_list_view.php
1 | <?php | 1 | <?php |
2 | use yii\helpers\ArrayHelper; | 2 | use yii\helpers\ArrayHelper; |
3 | use yii\helpers\Html; | 3 | use yii\helpers\Html; |
4 | +use yii\helpers\StringHelper; | ||
4 | 5 | ||
5 | 6 | ||
6 | ?> | 7 | ?> |
@@ -35,5 +36,5 @@ use yii\helpers\Html; | @@ -35,5 +36,5 @@ use yii\helpers\Html; | ||
35 | <div class="portfolio-project-views-txt">14</div> | 36 | <div class="portfolio-project-views-txt">14</div> |
36 | </div> | 37 | </div> |
37 | </div> | 38 | </div> |
38 | - <div class="portfolio-project-blocks-tags"><?= implode(',', ArrayHelper::getColumn($model->specializations,'specialization_name'))?></div> | 39 | + <div class="portfolio-project-blocks-tags"><?= ArrayHelper::getColumn($model->specializations,'specialization_name')[0]?></div> |
39 | </div> | 40 | </div> |
40 | \ No newline at end of file | 41 | \ No newline at end of file |