protected function loadPost() { $slug = $this->property('slug'); $post = new BlogPost(); $post = $post->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel') ? $post->transWhere('slug', $slug) : $post->where('slug', $slug); $post = $post->isPublished()->first(); /* * Add a "url" helper attribute for linking to each category */ if ($post && $post->categories->count()) { $post->categories->each(function ($category) { $category->setUrl($this->categoryPage, $this->controller); }); } return $post; }
/** * Override of original method * - add the post URL to the post entity * * @return mixed */ protected function loadPost() { $post = parent::loadPost(); $postPage = $this->property('postPage'); if ($post instanceof BlogPost) { $post->setUrl($postPage, $this->controller); } return $post; }