Example #1
0
 /**
  * Отображение списка фотографий категории
  * 
  * @param int $id
  */
 public function action_view($id = null)
 {
     is_null($id) and \Response::redirect('media/photos/categories');
     // Пагинация
     $config = array('pagination_url' => \URI::create('media/photos/categories/view/' . $id), 'total_items' => \Model_Media_Photo::count(array('where' => array(array('category_id', '=', $id)))), 'per_page' => 6, 'uri_segment' => 6);
     $pagination = \Pagination::forge('photos_pagination', $config);
     $data['pagination'] = $pagination->render();
     // Извлекаем данные категории
     $data['photos'] = \Model_Media_Photo::find('all', array('related' => 'category', 'where' => array(array('category_id', '=', $id)), 'order_by' => array('created_at' => 'DESC'), 'offset' => $pagination->offset, 'limit' => $pagination->per_page));
     $this->template->css = array('lightbox.css');
     $this->template->js = array('lightbox.min.js');
     $this->template->page_title = 'Медиа :: Фото :: ' . current($data['photos'])->category->title;
     $this->template->content = \View::forge('media/photos/categories/view', $data, FALSE);
 }
Example #2
0
 /**
  * Действие для отображения списка фотографий категории
  */
 public function action_index($category_id = NULL)
 {
     is_null($category_id) and \Response::redirect('admin/media/photos/categories');
     if (!($data['category'] = \Model_Media_Photos_Category::find($category_id))) {
         \Session::set_flash('error', 'Категория не найдена.');
         \Response::redirect('admin/media/photos/categories');
     }
     // Пагинация
     $config = array('pagination_url' => \URI::create('admin/media/photos/list/index/' . $category_id), 'total_items' => \Model_Media_Photo::count(array('where' => array(array('category_id' => $category_id)))), 'per_page' => 10, 'uri_segment' => 7);
     $pagination = \Pagination::forge('categories_pagination', $config);
     $data['pagination'] = $pagination->render();
     $data['photos'] = \Model_Media_Photo::find('all', array('where' => array(array('category_id', '=', $category_id)), 'order_by' => array('created_at' => 'DESC'), 'offset' => $pagination->offset, 'limit' => $pagination->per_page));
     $this->template->title = 'Фотогалерея "' . $data['category']->title . '"';
     $this->template->content = \View::forge('media/photos/list/index', $data, FALSE);
 }