Пример #1
0
 /**
  * Ładowanie danych posta z bazy
  * @return Post
  */
 protected function loadPost()
 {
     $this->categoryPage = $this->property('categoryPage');
     $this->category = Category::loadCategory($this->categoryPage);
     $post = BlogPost::published()->with('categories')->hasView()->slug($this->property('slug'))->where('category_id', $this->category->id)->first();
     return $post;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function onRun()
 {
     $this->category_page = $this->property('categoryPage');
     $this->wide = $this->property('wide') == true;
     $this->type = $this->property('type');
     $this->limit = $this->property('limit');
     $this->subcategories = $this->property('subcategories');
     $this->random = $this->property('random');
     $this->is_promoted = $this->property('is_promoted');
     $this->templates = $this->property('template');
     $this->partial = BoxSetting::find($this->type);
     $this->category = Category::loadCategory($this->category_page);
     $this->posts = BlogPost::getPosts(['post_id' => isset($this->page['post']) ? $this->page['post']->id : null, 'category' => $this->category, 'categories_id' => $this->property('categories_id'), 'limit' => $this->limit, 'template_id' => $this->templates, 'promoted' => $this->is_promoted, 'random' => $this->random, 'subcategories' => $this->subcategories]);
 }
Пример #3
0
 protected function prepareVars()
 {
     $this->pageParam = $this->paramName('pageNumber');
     $this->noPostsMessage = $this->property('noPostsMessage');
     $this->postPage = $this->property('postPage');
     $this->categoryPage = $this->property('categoryPage');
     $this->categoryParent = $this->property('categoryParent');
     $this->category = BlogCategory::loadCategory($this->categoryPage, $this->categoryParent);
     $this->template = $this->property('template') ?: (empty($this->category->template->partial_category) ? null : $this->category->template->partial_category);
     if (empty($this->category->id) || empty($this->category->template->id) && empty($this->template->id)) {
         return \Response::make($this->controller->run('404'), 404);
     }
     // paginacja domyślnie włączona; 'false' wyłącza
     $this->paginationActive = $this->category->pagination !== 'false' || $this->property('postsPerPage') > 0;
     $this->posts = BlogPost::getPosts(['category' => $this->category, 'categories_id' => $this->property('categories_id'), 'template_id' => $this->property('template_id') ?: $this->category->template_id, 'pagination' => $this->paginationActive, 'posts_per_page' => (int) $this->category->pagination > 0 ? $this->category->pagination : $this->property('postsPerPage'), 'page' => $this->property('pageNumber'), 'subcategories' => $this->property('subcategories'), 'order' => "NULLIF(regexp_replace(additional->>'order', E'\\D', '', 'g'), '')::int NULLS LAST, published_at DESC"]);
     $this->setMeta();
 }