1
0

When the display limit is specified, but there less than the display limit items, then use the item count as the display limit. 2nd attempt :-/

This commit is contained in:
Tim Almdal 2011-06-02 22:18:08 -07:00
parent fd55451395
commit d02ae95866
2 changed files with 16 additions and 20 deletions

View File

@ -31,18 +31,16 @@ class Dynamic_Controller extends Controller {
$album_defn = unserialize(module::get_var("dynamic", $album));
$display_limit = $album_defn->limit;
if (empty($display_limit)) {
$children_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->count_all();
} else {
$children_count = $display_limit;
$children_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->count_all();
if (!empty($display_limit)) {
$children_count = min($children_count, $display_limit);
}
$offset = ($page-1) * $page_size;
$max_pages = ceil($children_count / $page_size);
$offset = ($page - 1) * $page_size;
$max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) {

View File

@ -31,18 +31,16 @@ class Dynamic_Controller extends Controller {
$album_defn = unserialize(module::get_var("dynamic", $album));
$display_limit = $album_defn->limit;
if (empty($display_limit)) {
$children_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->count_all();
} else {
$children_count = $display_limit;
$children_count = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->count_all();
if (!empty($display_limit)) {
$children_count = min($children_count, $display_limit);
}
$offset = ($page-1) * $page_size;
$max_pages = ceil($children_count / $page_size);
$offset = ($page - 1) * $page_size;
$max_pages = max(ceil($children_count / $page_size), 1);
// Make sure that the page references a valid offset
if ($page < 1 || ($children_count && $page > ceil($children_count / $page_size))) {