Esempio n. 1
0
 public function before()
 {
     parent::before();
     View::bind_global('preview', $this->preview);
     if ($this->request->action() === 'index') {
         $this->page = Model_Page::find_by_slug($this->request->param('catcher'));
     } else {
         if (!Can::show()) {
             throw new Kohana_Exception("Permission Denied.");
         }
         $this->preview = TRUE;
         if ($this->request->query('preview') !== NULL) {
             $this->preview = (bool) $this->request->query('preview');
         }
         if ($this->request->query('id_page') !== NULL) {
             $id_page = (bool) $this->request->query('id_page');
             $this->page = Model_Page::factory('Page')->where('id_page', '=', $id_page)->order_by('id', 'DESC')->find();
             dd($this->page);
         } else {
             $page_id = (int) $this->request->param('id');
             $this->page = Model_Page::factory('Page', $page_id);
         }
     }
     View::bind_global('page', $this->page);
     $this->content = $this->page->render_blocks();
 }
Esempio n. 2
0
 public static function slug_exists($slug)
 {
     return Model_Page::find_by_slug($slug)->loaded();
 }