Example #1
0
 public function onStart()
 {
     $slug = $this->param('slug');
     $this['post'] = Post::where('slug', '=', $slug)->isPublished()->first();
     if (!$this['post']) {
         return Redirect::to('/404');
     }
     $this->page->settings['title'] = $this["post"]->title;
 }
Example #2
0
 protected function listPosts()
 {
     $posts = NewsPost::listFrontEnd(['page' => $this->property('pageNumber'), 'sort' => $this->property('sortOrder'), 'perPage' => $this->property('postsPerPage')]);
     return $posts;
 }
Example #3
0
 public function onStart()
 {
     $this['posts'] = Post::isPublished()->orderBy('published_at', 'desc')->take(2)->get();
 }
Example #4
0
 protected function loadPost()
 {
     $slug = $this->property('slug');
     $post = NewsPost::isPublished()->where('slug', $slug)->first();
     return $post;
 }