From f9570cf9b574de292084242f11e4915e198e497c Mon Sep 17 00:00:00 2001 From: andryeyev Date: Thu, 12 Nov 2015 13:00:31 +0200 Subject: [PATCH] fix: Загрузка старниц --- common/models/Page.php | 7 +++++-- db-migration/artbox_db.sql | 37 +++++++++++++++++++------------------ frontend/config/main.php | 3 +-- frontend/controllers/PageController.php | 2 +- frontend/views/page/page.php | 2 +- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/common/models/Page.php b/common/models/Page.php index 89c977c..bb68bbf 100644 --- a/common/models/Page.php +++ b/common/models/Page.php @@ -107,7 +107,7 @@ class Page extends \yii\db\ActiveRecord { return yii::$app->db->createCommand(' SELECT - `termin`.show, `termin`.termin_id, + `termin`.show, `termin`.termin_id, `termin`.page_id, `controller`.controller_name, `template`.template_file FROM `termin` @@ -129,8 +129,11 @@ class Page extends \yii\db\ActiveRecord return yii::$app->db->createCommand(' SELECT * FROM `termin` - INNER JOIN `termin_lang` ON `termin_lang`.page_id = `termin`.termin_id + INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `termin`.termin_id AND `termin_lang`.lang_id = '.yii::$app->lang_id.' + INNER JOIN `page` ON `page`.page_id = `termin`.page_id + INNER JOIN `page_lang` ON `page_lang`.page_id = `page`.page_id + AND `page_lang`.lang_id = '.yii::$app->lang_id.' WHERE `termin`.termin_id = "'.(int)$page_id.'" ')->queryOne(); } diff --git a/db-migration/artbox_db.sql b/db-migration/artbox_db.sql index 97affa2..ef85b34 100644 --- a/db-migration/artbox_db.sql +++ b/db-migration/artbox_db.sql @@ -3,7 +3,7 @@ -- http://www.phpmyadmin.net -- -- Хост: 127.0.0.1:3306 --- Час створення: Лис 12 2015 р., 13:15 +-- Час створення: Лис 12 2015 р., 13:59 -- Версія сервера: 5.5.45 -- Версія PHP: 5.6.12 @@ -388,6 +388,7 @@ INSERT INTO `template_lang` (`template_id`, `template_title`, `lang_id`) VALUES CREATE TABLE IF NOT EXISTS `termin` ( `termin_id` int(6) NOT NULL AUTO_INCREMENT, `template_id` int(6) NOT NULL, + `page_id` int(6) NOT NULL, `show` tinyint(1) NOT NULL, PRIMARY KEY (`termin_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ; @@ -396,23 +397,23 @@ CREATE TABLE IF NOT EXISTS `termin` ( -- Дамп даних таблиці `termin` -- -INSERT INTO `termin` (`termin_id`, `template_id`, `show`) VALUES -(1, 2, 1), -(2, 2, 1), -(3, 2, 1), -(4, 2, 1), -(5, 2, 1), -(6, 2, 1), -(7, 2, 1), -(8, 2, 1), -(9, 2, 1), -(10, 2, 1), -(11, 2, 1), -(12, 2, 1), -(13, 2, 1), -(14, 2, 1), -(15, 2, 1), -(16, 2, 1); +INSERT INTO `termin` (`termin_id`, `template_id`, `page_id`, `show`) VALUES +(1, 2, 1, 1), +(2, 1, 2, 1), +(3, 1, 3, 1), +(4, 1, 4, 1), +(5, 1, 5, 1), +(6, 1, 6, 1), +(7, 1, 7, 1), +(8, 1, 8, 1), +(9, 1, 9, 1), +(10, 1, 10, 1), +(11, 1, 11, 1), +(12, 1, 12, 1), +(13, 1, 13, 1), +(14, 1, 14, 1), +(15, 1, 15, 1), +(16, 1, 16, 1); -- -------------------------------------------------------- diff --git a/frontend/config/main.php b/frontend/config/main.php index 4260c4b..1f58b6a 100644 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -35,8 +35,7 @@ return [ 'showScriptName' => false, 'rules' => [ '' => 'site/index', - '/' => '/', - 'contacts' => 'page/page' + '/' => '/', ] ], ], diff --git a/frontend/controllers/PageController.php b/frontend/controllers/PageController.php index 2202855..7e6193d 100644 --- a/frontend/controllers/PageController.php +++ b/frontend/controllers/PageController.php @@ -16,7 +16,7 @@ class PageController extends Controller * @return mixed */ public function actionPage($controller_name, $page_id, $template_file) - { die; + { // страница $page = Page::getPageById ($page_id); diff --git a/frontend/views/page/page.php b/frontend/views/page/page.php index ac3c2b1..1b37f65 100644 --- a/frontend/views/page/page.php +++ b/frontend/views/page/page.php @@ -8,5 +8,5 @@ use yii\helpers\Html; // JS $this->registerJsFile('script.js'); - echo Html::encode($text); + echo $text; ?> \ No newline at end of file -- libgit2 0.21.4