Ejemplo n.º 1
0
 protected function loadArticle()
 {
     $slug = $this->property('slug');
     $article = ArticleModel::isPublished()->where('slug', $slug)->first();
     /*
      * Add a "url" helper attribute for linking to each category
      */
     if ($article && $article->categories->count()) {
         $article->categories->each(function ($category) {
             $category->setUrl($this->categoryPage, $this->controller);
         });
     }
     CW::info(['Press' => $article]);
     return $article;
 }
Ejemplo n.º 2
0
 protected function listArticles()
 {
     $categories = $this->category ? $this->category->id : null;
     /*
      * List all the articles, eager load their categories
      */
     $articles = ArticleModel::with('categories')->listFrontEnd(['page' => $this->property('pageNumber'), 'perPage' => $this->property('articlesPerPage'), 'categories' => $categories]);
     /*
      * Add a "url" helper attribute for linking to each article and category
      */
     $articles->each(function ($article) {
         $article->setUrl($this->articlePage, $this->controller);
         $article->categories->each(function ($category) {
             $category->setUrl($this->categoryPage, $this->controller);
         });
     });
     CW::info(['PressArchive' => $articles]);
     return $articles;
 }
Ejemplo n.º 3
0
 public function boot()
 {
     $alias = AliasLoader::getInstance();
     $alias->alias('Carbon', '\\Carbon\\Carbon');
     $alias->alias('CW', '\\Clockwork\\Support\\Laravel\\Facade');
     /*
      * Register menu items for the RainLab.Pages plugin
      */
     Event::listen('pages.menuitem.listTypes', function () {
         return ['pressarchive' => 'Архив новостей'];
     });
     Event::listen('pages.menuitem.getTypeInfo', function ($type) {
         if ($type == 'pressarchive') {
             return ArticleModel::getMenuTypeInfo($type);
         }
     });
     Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
         if ($type == 'pressarchive') {
             return ArticleModel::resolveMenuItem($item, $url, $theme);
         }
     });
 }