Exemplo n.º 1
0
 private function findPage($id_slug)
 {
     //aslinya            $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     if (is_integer($id_slug)) {
         $page = PageModel::find()->where('page_id=:id_slug', [':id_slug' => $id_slug])->one();
     } else {
         $page = PageModel::find()->where('slug=:id_slug', [':id_slug' => $id_slug])->one();
     }
     return $page ? new PageObject($page) : $this->notFound($id_slug);
 }
Exemplo n.º 2
0
 public function actionPage($slug)
 {
     $menuItems = [];
     foreach (Page::find()->all() as $model) {
         $menuItems[] = ['label' => $model->title, 'url' => ['site/page', 'slug' => $model->slug]];
     }
     $page = Page::findOne(['slug' => $slug]);
     if (!$page) {
         throw new NotFoundHttpException();
     }
     return $this->render('page', ['page' => $page, 'menuItems' => $menuItems]);
 }
Exemplo n.º 3
0
 private function findPage($id_slug)
 {
     $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     if ($page) {
         $result = $this->parsePage($page);
         $result->seo_h1 = $page->seo_h1;
         $result->seo_title = $page->seo_title;
         $result->seo_keywords = $page->seo_keywords;
         $result->seo_description = $page->seo_description;
         return $result;
     } else {
         return $this->notFound($id_slug);
     }
 }
Exemplo n.º 4
0
 public function init()
 {
     $items = [['label' => 'Главная', 'url' => '/']];
     $page = Page::find()->one();
     if ($page) {
         $items[] = ['label' => 'О компании', 'url' => ['site/page', 'slug' => $page->slug]];
     }
     foreach (Article::tree() as $articleCategory) {
         $item['label'] = $articleCategory->title;
         if (count($articleCategory->children) > 0) {
             $item['url'] = ['site/article', 'category' => $articleCategory->children[0]->slug];
         } else {
             $item['url'] = ['site/article', 'category' => $articleCategory->slug];
         }
         $items[] = $item;
     }
     $items[] = ['label' => 'Новостная лента', 'url' => ['site/news']];
     $this->items = $items;
 }
 public function insertPages()
 {
     if (Page::find()->count()) {
         return '`<b>' . Page::tableName() . '</b>` table is not empty, skipping...';
     }
     $this->db->createCommand('TRUNCATE TABLE `' . Page::tableName() . '`')->query();
     $page1 = new Page(['title' => 'Index', 'text' => '<p><strong>All elements are live-editable, switch on Live Edit button to see this feature.</strong>&nbsp;</p><p>Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&nbsp;Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>', 'slug' => 'page-index']);
     $page1->save();
     $this->attachSeo($page1, '', 'EasyiiCMS demo', 'yii2, easyii, admin');
     $page2 = new Page(['title' => 'Shop', 'text' => '', 'slug' => 'page-shop']);
     $page2->save();
     $this->attachSeo($page2, 'Shop categories', 'Extended shop title');
     $page3 = new Page(['title' => 'Shop search', 'text' => '', 'slug' => 'page-shop-search']);
     $page3->save();
     $this->attachSeo($page3, 'Shop search results', 'Extended shop search title');
     $page4 = new Page(['title' => 'Shopping cart', 'text' => '', 'slug' => 'page-shopcart']);
     $page4->save();
     $this->attachSeo($page4, 'Shopping cart H1', 'Extended shopping cart title');
     $page5 = new Page(['title' => 'Order created', 'text' => '<p>Your order successfully created. Our manager will contact you as soon as possible.</p>', 'slug' => 'page-shopcart-success']);
     $page5->save();
     $this->attachSeo($page5, 'Success', 'Extended order success title');
     $page6 = new Page(['title' => 'News', 'text' => '', 'slug' => 'page-news']);
     $page6->save();
     $this->attachSeo($page6, 'News H1', 'Extended news title');
     $page7 = new Page(['title' => 'Articles', 'text' => '', 'slug' => 'page-articles']);
     $page7->save();
     $this->attachSeo($page7, 'Articles H1', 'Extended articles title');
     $page8 = new Page(['title' => 'Gallery', 'text' => '', 'slug' => 'page-gallery']);
     $page8->save();
     $this->attachSeo($page8, 'Photo gallery', 'Extended gallery title');
     $page9 = new Page(['title' => 'Guestbook', 'text' => '', 'slug' => 'page-guestbook']);
     $page9->save();
     $this->attachSeo($page9, 'Guestbook H1', 'Extended guestbook title');
     $page10 = new Page(['title' => 'FAQ', 'text' => '', 'slug' => 'page-faq']);
     $page10->save();
     $this->attachSeo($page10, 'Frequently Asked Question', 'Extended faq title');
     $page11 = new Page(['title' => 'Contact', 'text' => '<p><strong>Address</strong>: Dominican republic, Santo Domingo, Some street 123</p><p><strong>ZIP</strong>: 123456</p><p><strong>Phone</strong>: +1 234 56-78</p><p><strong>E-mail</strong>: demo@example.com</p>', 'slug' => 'page-contact']);
     $page11->save();
     $this->attachSeo($page11, 'Contact us', 'Extended contact title');
     return 'Page data inserted.';
 }
Exemplo n.º 6
0
 private function findPage($id_slug)
 {
     $page = PageModel::find()->where(['or', 'page_id=:id_slug', 'slug=:id_slug'], [':id_slug' => $id_slug])->one();
     return $page ? new PageObject($page) : $this->notFound($id_slug);
 }
Exemplo n.º 7
0
 public function actionIndex()
 {
     $data = new ActiveDataProvider(['query' => Page::find()->desc()]);
     return $this->render('index', ['data' => $data]);
 }