public function read() { $f3 = \Base::instance(); $slug = $this->inputfilter->clean($f3->get('PARAMS.slug'), 'cmd'); $model = $this->getModel()->populateState()->setState('filter.slug', $slug); $preview = $this->input->get("preview", 0, 'int'); if ($preview) { $this->canPreview(); } else { $model->setState('filter.published_today', true)->setState('filter.publication_status', 'published'); } try { $item = $model->getItem(); if (empty($item->id)) { throw new \Exception(); } // increase the view count $item->hit(); } catch (\Exception $e) { \Dsc\System::instance()->addMessage("Invalid Item", 'error'); $f3->reroute('/blog'); return; } $author = $this->getModel('users')->setState('filter.id', $item->{'author.id'})->getItem(); $related = $item->getRelatedPosts(); \Base::instance()->set('item', $item); \Base::instance()->set('author', $author); \Base::instance()->set('related', $related); $this->app->set('meta.title', $item->seoTitle() . ' | Blog'); $this->app->set('meta.description', $item->seoDescription()); \Blog\Models\Activities::track('Viewed Blog Post', array('Blog Title' => $item->seoTitle(), 'post_id' => (string) $item->id)); $view = \Dsc\System::instance()->get('theme'); echo $view->render('Blog/Site/Views::posts/view.php'); }
public function index() { $f3 = \Base::instance(); $model = $this->getModel(); try { $paginated = $model->populateState()->setState('filter.publication_status', 'published')->setState('filter.published_today', true)->paginate(); } catch (\Exception $e) { \Dsc\System::instance()->addMessage("Error loading Blog", 'error'); $f3->reroute('/'); return; } $state = $model->getState(); \Base::instance()->set('state', $state); \Base::instance()->set('paginated', $paginated); $this->app->set('meta.title', 'Blog'); \Blog\Models\Activities::track('Viewed Blog Home', array('page_number' => $paginated->current_page)); $view = \Dsc\System::instance()->get('theme'); echo $view->render('Blog/Site/Views::home/index.php'); }