Inheritance: extends Cms\Classes\ComponentBase
Ejemplo n.º 1
0
 public function boot()
 {
     PostComponent::extend(function ($component) {
         if ($this->app->runningInBackend()) {
             return;
         }
         if (!Session::has('postsviewed')) {
             Session::put('postsviewed', []);
         }
         $post = PostModel::where('slug', $component->getController()->getRouter()->getParameters()['slug'])->first();
         if (!is_null($post) && !in_array($post->getKey(), Session::get('postsviewed'))) {
             $this->setViews($post);
             Session::push('postsviewed', $post->getKey());
         }
         return true;
     });
 }
Ejemplo n.º 2
0
 /**
  * Override of original method
  * - add new setting for the post page id
  *
  * @return array
  */
 public function defineProperties()
 {
     $parentProps = parent::defineProperties();
     $properties = array_merge($parentProps, ['postPage' => ['title' => 'rainlab.blog::lang.settings.posts_post', 'description' => 'rainlab.blog::lang.settings.posts_post_description', 'type' => 'dropdown', 'default' => 'blog/post', 'group' => 'Links']]);
     return is_array($properties) ? $properties : $parentProps;
 }