예제 #1
0
 public function action_index()
 {
     $contenttype = $this->check_contenttype();
     $contents = $contenttype->contents;
     $counter = $contenttype->contents;
     if ((bool) $contenttype->supports('hierarchy')) {
         $contents = $contents->where('parent', '=', 0);
         $counter = $counter->where('parent', '=', 0);
     }
     if ($contenttype->supports('timestamp')) {
         $contents = $contents->order_by('created', 'DESC');
     }
     $contents = $contents->where('splittest', '=', 0);
     $numresults = $counter->count_all();
     $limit = 20;
     $offset = cms::offset($numresults, $limit);
     $contents = $contents->limit($limit)->offset($offset);
     $contents = $this->loop_content_rows($contents->find_all());
     $pagination = cms::pagination($numresults, '#/content/index/' . $contenttype->id, $limit);
     $view = View::factory('Cms/Content/index2');
     $view->contenttype = $contenttype;
     $view->pagination = $pagination;
     $allcontent = DB::select('id', 'title')->from('contents')->where('contenttype_id', '=', $contenttype->id)->execute()->as_array();
     reply::ok($view, 'contenttype-' . $contenttype->id, array('viewModel' => 'viewModels/Content/index', 'contents' => $contents, 'contenttype' => $contenttype->baseinfo(), 'allcontent' => $allcontent));
 }