Skip to content

Commit c3457b9

Browse files
committed
main page articles
1 parent 61c82cf commit c3457b9

File tree

16 files changed

+103
-233
lines changed

16 files changed

+103
-233
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"yiisoft/yii2-swiftmailer": "^2.0.0",
3535
"yiisoft/yii2-authclient": "^2.0.0",
3636
"yiisoft/yii2-jui": "^2.0.0",
37-
"asofter/yii2-imperavi-redactor": "^0.0.3",
37+
"asofter/yii2-imperavi-redactor": "@dev",
3838
"mihaildev/yii2-elfinder": "^1.0",
3939
"trntv/yii2-aceeditor": "^2.0",
4040
"trntv/probe": "^0.2",

composer.lock

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/config/_urlManager.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
'rules' => [
77

88
// Pages
9+
'/' => '/site/index',
10+
'/category/<category_id>' => 'site/index',
11+
912
['pattern' => 'page/<slug>', 'route' => 'page/view'],
10-
11-
// Articles
12-
['pattern' => 'article/index', 'route' => 'article/index'],
13+
1314
['pattern' => 'article/attachment-download', 'route' => 'article/attachment-download'],
1415
['pattern' => 'article/<slug>', 'route' => 'article/view'],
1516

frontend/controllers/ArticleController.php

-12
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@
1616
*/
1717
class ArticleController extends Controller
1818
{
19-
/**
20-
* @return string
21-
*/
22-
public function actionIndex()
23-
{
24-
$searchModel = new ArticleSearch();
25-
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
26-
$dataProvider->sort = [
27-
'defaultOrder' => ['created_at' => SORT_DESC]
28-
];
29-
return $this->render('index', ['dataProvider' => $dataProvider]);
30-
}
3119

3220
/**
3321
* @param $slug

frontend/controllers/SiteController.php

+8-26
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
use Yii;
66
use yii\web\Controller;
7+
use yii\web\NotFoundHttpException;
78

8-
use frontend\models\ContactForm;
9-
9+
use frontend\models\search\ArticleSearch;
1010
/**
1111
* Site controller
1212
*/
@@ -34,29 +34,11 @@ public function actions()
3434

3535
public function actionIndex()
3636
{
37-
return $this->render('index');
38-
}
39-
40-
public function actionContact()
41-
{
42-
$model = new ContactForm();
43-
if ($model->load(Yii::$app->request->post())) {
44-
if ($model->contact(Yii::$app->params['adminEmail'])) {
45-
Yii::$app->getSession()->setFlash('alert', [
46-
'body' => Yii::t('frontend', 'Thank you for contacting us. We will respond to you as soon as possible.'),
47-
'options' => ['class' => 'alert-success']
48-
]);
49-
return $this->refresh();
50-
} else {
51-
Yii::$app->getSession()->setFlash('alert', [
52-
'body' => \Yii::t('frontend', 'There was an error sending email.'),
53-
'options' => ['class' => 'alert-danger']
54-
]);
55-
}
56-
}
57-
58-
return $this->render('contact', [
59-
'model' => $model
60-
]);
37+
$searchModel = new ArticleSearch();
38+
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
39+
$dataProvider->sort = [
40+
'defaultOrder' => ['created_at' => SORT_DESC]
41+
];
42+
return $this->render('index', ['dataProvider' => $dataProvider]);
6143
}
6244
}

frontend/models/ContactForm.php

-70
This file was deleted.

frontend/models/search/ArticleSearch.php

+5
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ public function search($params)
5858

5959
return $dataProvider;
6060
}
61+
62+
public function formName() {
63+
return '';
64+
}
65+
6166
}

frontend/views/article/_item.php

-42
This file was deleted.

frontend/views/article/index.php

-14
This file was deleted.

frontend/views/article/view.php

100755100644
+20-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
<?php
2+
3+
use yii\helpers\Html;
4+
25
/* @var $this yii\web\View */
36
/* @var $model common\models\Article */
47
$this->title = $model->title;
5-
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend', 'Articles'), 'url' => ['index']];
6-
$this->params['breadcrumbs'][] = $this->title;
8+
Yii::$app->params['breadcrumbs'][] = $this->title;
79
?>
810
<div class="content">
9-
<article class="article-item">
10-
<h1><?php echo $model->title ?></h1>
11-
11+
<article class="article-item flat">
12+
<h2 class="article-title">
13+
<?php echo $model->title ?>
14+
</h2>
15+
1216
<?php if ($model->thumbnail_path): ?>
1317
<?php echo \yii\helpers\Html::img(
1418
Yii::$app->glide->createSignedUrl([
@@ -19,7 +23,17 @@
1923
['class' => 'article-thumb img-rounded pull-left']
2024
) ?>
2125
<?php endif; ?>
22-
26+
<div class="article-meta">
27+
<span class="article-date">
28+
<?php echo Yii::$app->formatter->asDatetime($model->created_at) ?>
29+
</span>,
30+
<span class="article-category">
31+
<?php echo Html::a(
32+
$model->category->title,
33+
['/category/' . $model->category_id]
34+
)?>
35+
</span>
36+
</div>
2337
<?php echo $model->body ?>
2438

2539
<?php if (!empty($model->articleAttachments)): ?>

frontend/views/layouts/base.php

-14
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,6 @@
5555
'data-hover' => Yii::t('frontend', 'About'),
5656
],
5757
],
58-
[
59-
'label' => Yii::t('frontend', 'Articles'),
60-
'url' => ['/article/index'],
61-
'linkOptions' => [
62-
'data-hover' => Yii::t('frontend', 'Articles'),
63-
],
64-
],
6558
[
6659
'label' => Yii::t('armory', 'Армори'),
6760
'url' => ['/armory/main/index'],
@@ -76,13 +69,6 @@
7669
'data-hover' => Yii::t('ladder', 'Ладдер'),
7770
],
7871
],
79-
[
80-
'label' => Yii::t('frontend', 'Contact'),
81-
'url' => ['/site/contact'],
82-
'linkOptions' => [
83-
'data-hover' => Yii::t('frontend', 'Contact'),
84-
],
85-
],
8672
[
8773
'label' => Yii::t('frontend', 'Signup'),
8874
'url' => ['/panel/sign-in/signup'],

frontend/views/layouts/main.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727

2828
<div class="row">
2929
<div class="col-md-8" id="left-side">
30-
<div class="flat">
31-
<?php echo $content ?>
32-
</div>
30+
<?php echo $content ?>
3331
</div>
3432
<div class="col-md-4" id="right-side">
3533
<?= StatusServersWidget::widget() ?>

0 commit comments

Comments
 (0)