Changeset 2577:9a2b43a68e3d for inc/public
- Timestamp:
- 11/21/13 15:11:09 (12 years ago)
- Branch:
- default
- Location:
- inc/public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/public/class.dc.template.php
r2574 r2577 1042 1042 1043 1043 if ($lastn != 0) { 1044 // Set limit (aka nb of entries needed) 1044 1045 if ($lastn > 0) { 1046 // nb of entries per page specified in template -> regular pagination 1045 1047 $p .= "\$params['limit'] = ".$lastn.";\n"; 1046 1048 } else { 1047 $p .= "\$params['limit'] = \$_ctx->nb_entry_per_page;\n"; 1049 // nb of entries per page not specified -> use ctx settings 1050 $p .= "\$params['limit'] = (\$_page_number == 1 ? \$_ctx->nb_entry_first_page : \$_ctx->nb_entry_per_page);\n"; 1048 1051 } 1049 1052 // Set offset (aka index of first entry) 1050 1053 if (!isset($attr['ignore_pagination']) || $attr['ignore_pagination'] == "0") { 1051 $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; 1054 // standard pagination, set offset 1055 $p .= "\$params['limit'] = array((\$_page_number == 1 ? 0 : (\$_page_number - 2) * \$_ctx->nb_entry_per_page + \$_ctx->nb_entry_first_page),\$params['limit']);\n"; 1052 1056 } else { 1057 // no pagination, get all posts from 0 to limit 1053 1058 $p .= "\$params['limit'] = array(0, \$params['limit']);\n"; 1054 1059 } -
inc/public/lib.tpl.context.php
r2566 r2577 206 206 207 207 $nb_posts = $_ctx->pagination->f(0); 208 $nb_per_page = $_ctx->post_params['limit'][1]; 209 210 $nb_pages = ceil($nb_posts/$nb_per_page); 208 $nb_pages = ceil(($nb_posts - $_ctx->nb_entry_first_page) / $_ctx->nb_entry_per_page + 1); 211 209 212 210 return $nb_pages; -
inc/public/lib.urlhandlers.php
r2566 r2577 86 86 $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page; 87 87 } 88 if ($_ctx->nb_entry_first_page === null) { 89 $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page; 90 } 88 91 89 92 $tpl_file = $core->tpl->getFilePath($tpl); … … 188 191 else 189 192 { 193 $_ctx =& $GLOBALS['_ctx']; 190 194 $core =& $GLOBALS['core']; 191 195 … … 196 200 197 201 if (empty($_GET['q'])) { 202 if ($core->blog->settings->system->nb_post_for_home !== null) { 203 $_ctx->nb_entry_first_page = $core->blog->settings->system->nb_post_for_home; 204 } 198 205 self::serveDocument('home.html'); 199 206 $core->blog->publishScheduledEntries();
Note: See TracChangeset
for help on using the changeset viewer.