Dotclear


Ignore:
Timestamp:
11/21/13 15:11:09 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Number of entries on first home page may be set (does not modify number of entries on other pages), fixes #1269

Location:
inc/public
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/public/class.dc.template.php

    r2574 r2577  
    10421042 
    10431043          if ($lastn != 0) { 
     1044               // Set limit (aka nb of entries needed) 
    10441045               if ($lastn > 0) { 
     1046                    // nb of entries per page specified in template -> regular pagination 
    10451047                    $p .= "\$params['limit'] = ".$lastn.";\n"; 
    10461048               } 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"; 
    10481051               } 
    1049  
     1052               // Set offset (aka index of first entry) 
    10501053               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"; 
    10521056               } else { 
     1057                    // no pagination, get all posts from 0 to limit 
    10531058                    $p .= "\$params['limit'] = array(0, \$params['limit']);\n"; 
    10541059               } 
  • inc/public/lib.tpl.context.php

    r2566 r2577  
    206206 
    207207          $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); 
    211209 
    212210          return $nb_pages; 
  • inc/public/lib.urlhandlers.php

    r2566 r2577  
    8686               $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page; 
    8787          } 
     88          if ($_ctx->nb_entry_first_page === null) { 
     89               $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page; 
     90          } 
    8891 
    8992          $tpl_file = $core->tpl->getFilePath($tpl); 
     
    188191          else 
    189192          { 
     193               $_ctx =& $GLOBALS['_ctx']; 
    190194               $core =& $GLOBALS['core']; 
    191195 
     
    196200 
    197201               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                    } 
    198205                    self::serveDocument('home.html'); 
    199206                    $core->blog->publishScheduledEntries(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map