コード例 #1
0
 protected function listTowns()
 {
     $towns = TownModel::isEnabled()->paginate($this->property('postsPerPage'), $this->property('pageNumber'));
     // set town URL depends on configured town page parameter
     $towns->each(function ($post) {
         $post->setUrl($this->townPage, $this->controller);
     });
     return $towns;
 }
コード例 #2
0
 /**
  * Register new MenuItems, which is usefull for Sitemap and etc.
  */
 public function initMenuItems()
 {
     Event::listen('pages.menuitem.listTypes', function () {
         return ['location-town' => 'Location Town', 'all-location-towns' => 'All location towns'];
     });
     Event::listen('pages.menuitem.getTypeInfo', function ($type) {
         if ($type == 'location-town' || $type == 'all-location-towns') {
             return Town::getMenuTypeInfo($type);
         }
     });
     Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
         if ($type == 'location-town' || $type == 'all-location-towns') {
             return Town::resolveMenuItem($item, $url, $theme);
         }
     });
 }
コード例 #3
0
 protected function loadTown()
 {
     $slug = $this->property('slug');
     return TownModel::where('slug', $slug)->isEnabled()->first();
 }