当前位置: 首页>>代码示例>>PHP>>正文


PHP NewsModel::countPublishedByPids方法代码示例

本文整理汇总了PHP中NewsModel::countPublishedByPids方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsModel::countPublishedByPids方法的具体用法?PHP NewsModel::countPublishedByPids怎么用?PHP NewsModel::countPublishedByPids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NewsModel的用法示例。


在下文中一共展示了NewsModel::countPublishedByPids方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $offset = intval($this->skipFirst);
     $limit = null;
     // Maximum number of items
     if ($this->numberOfItems > 0) {
         $limit = $this->numberOfItems;
     }
     // Handle featured news
     if ($this->news_featured == 'featured') {
         $blnFeatured = true;
     } elseif ($this->news_featured == 'unfeatured') {
         $blnFeatured = false;
     } else {
         $blnFeatured = null;
     }
     $this->Template->articles = array();
     $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyList'];
     // Get the total number of items
     $intTotal = \NewsModel::countPublishedByPids($this->news_archives, $blnFeatured);
     if ($intTotal < 1) {
         return;
     }
     $total = $intTotal - $offset;
     // Split the results
     if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage)) {
         // Adjust the overall limit
         if (isset($limit)) {
             $total = min($limit, $total);
         }
         // Get the current page
         $id = 'page_n' . $this->id;
         $page = \Input::get($id) ?: 1;
         // Do not index or cache the page if the page number is outside the range
         if ($page < 1 || $page > max(ceil($total / $this->perPage), 1)) {
             global $objPage;
             $objPage->noSearch = 1;
             $objPage->cache = 0;
             // Send a 404 header
             header('HTTP/1.1 404 Not Found');
             return;
         }
         // Set limit and offset
         $limit = $this->perPage;
         $offset += (max($page, 1) - 1) * $this->perPage;
         $skip = intval($this->skipFirst);
         // Overall limit
         if ($offset + $limit > $total + $skip) {
             $limit = $total + $skip - $offset;
         }
         // Add the pagination menu
         $objPagination = new \Pagination($total, $this->perPage, \Config::get('maxPaginationLinks'), $id);
         $this->Template->pagination = $objPagination->generate("\n  ");
     }
     // Get the items
     if (isset($limit)) {
         $objArticles = \NewsModel::findPublishedByPids($this->news_archives, $blnFeatured, $limit, $offset);
     } else {
         $objArticles = \NewsModel::findPublishedByPids($this->news_archives, $blnFeatured, 0, $offset);
     }
     // Add the articles
     if ($objArticles !== null) {
         $this->Template->articles = $this->parseArticles($objArticles);
     }
     $this->Template->archives = $this->news_archives;
 }
开发者ID:iCodr8,项目名称:core,代码行数:69,代码来源:ModuleNewsList.php

示例2: countItems

 /**
  * Count the total matching items
  *
  * @param array $newsArchives
  * @param boolean $blnFeatured
  *
  * @return integer
  */
 protected function countItems($newsArchives, $blnFeatured)
 {
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['newsListCountItems']) && is_array($GLOBALS['TL_HOOKS']['newsListCountItems'])) {
         foreach ($GLOBALS['TL_HOOKS']['newsListCountItems'] as $callback) {
             if (($intResult = \System::importStatic($callback[0])->{$callback[1]}($newsArchives, $blnFeatured, $this)) === false) {
                 continue;
             }
             if (is_int($intResult)) {
                 return $intResult;
             }
         }
     }
     return \NewsModel::countPublishedByPids($newsArchives, $blnFeatured);
 }
开发者ID:bytehead,项目名称:contao-core,代码行数:23,代码来源:ModuleNewsList.php


注:本文中的NewsModel::countPublishedByPids方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。