Пример #1
0
 protected function listPosts()
 {
     /*
      * List all the posts, eager load their categories
      */
     $posts = BlogPost::listFrontEnd(['page' => $this->property('pageNumber'), 'sort' => $this->property('sortOrder'), 'perPage' => $this->property('postsPerPage')]);
     /*
      * Add a "url" helper attribute for linking to each post and category
      */
     $posts->each(function ($post) {
         $post->setUrl($this->postPage, $this->controller);
     });
     return $posts;
 }
Пример #2
0
 /**
  * Load the blog posts
  *
  * @param int $maxItems
  *
  * @return mixed
  */
 public function loadData($maxItems = self::MAX_NO_ITEMS)
 {
     $posts = null;
     if (!empty($this->data)) {
         return $this->data;
     }
     $model = new Post();
     $posts = $model->listFrontEnd(['sort' => 'published_at DESC', 'perPage' => $maxItems]);
     foreach ($posts as $post) {
         $post->setUrl($this->page, $this->controller);
         $post->comments_url = "{$post->url}/#{$this->commentsAnchor}";
         $post->feed_content = true === $this->displayFullContent ? $post->content : $post->summary;
     }
     return $this->data = $posts;
 }