protected function compile()
	{
		$limit = null;
		$offset = (int) $this->skipFirst;

		// 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 = $this->countItems($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))
			{
				throw new PageNotFoundException('Page not found: ' . Environment::get('uri'));
			}

			// Set limit and offset
			$limit = $this->perPage;
			$offset += (max($page, 1) - 1) * $this->perPage;
			$skip = (int) $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  ");
		}

		$objArticles = $this->fetchItems($this->news_archives, $blnFeatured, ($limit ?: 0), $offset);

		// Add the articles
		if ($objArticles !== null)
		{
			$this->Template->articles = $this->parseArticles($objArticles);
		}

		$this->Template->archives = $this->news_archives;
	}
protected function compile()
	{
		$limit = null;
		$offset = (int) $this->skipFirst;

		
		if ($this->numberOfItems > 0)
		{
			$limit = $this->numberOfItems;
		}

		
		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'];

		
		$intTotal = $this->countItems($this->news_archives, $blnFeatured);

		if ($intTotal < 1)
		{
			return;
		}

		$total = $intTotal - $offset;

		
		if ($this->perPage > 0 && (!isset($limit) || $this->numberOfItems > $this->perPage))
		{
			
			if (isset($limit))
			{
				$total = min($limit, $total);
			}

			
			$id = 'page_n' . $this->id;
			$page = Input::get($id) ?? 1;

			
			if ($page < 1 || $page > max(ceil($total/$this->perPage), 1))
			{
				throw new PageNotFoundException('Page not found: ' . Environment::get('uri'));
			}

			
			$limit = $this->perPage;
			$offset += (max($page, 1) - 1) * $this->perPage;
			$skip = (int) $this->skipFirst;

			
			if ($offset + $limit > $total + $skip)
			{
				$limit = $total + $skip - $offset;
			}

			
			$objPagination = new Pagination($total, $this->perPage, Config::get('maxPaginationLinks'), $id);
			$this->Template->pagination = $objPagination->generate("\n  ");
		}

		$objArticles = $this->fetchItems($this->news_archives, $blnFeatured, ($limit ?: 0), $offset);

		
		if ($objArticles !== null)
		{
			$this->Template->articles = $this->parseArticles($objArticles);
		}

		$this->Template->archives = $this->news_archives;
	}
protected function compile ( ) { $ limit = null ; $ offset = ( int ) $ this -> skipFirst ; // 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 = $ this -> countItems ( $ 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 ) ) { throw new PageNotFoundException ( 'Page not found: ' . Environment :: get ( 'uri' ) ) ; } // Set limit and offset $ limit = $ this -> perPage ; $ offset += ( max ( $ page , 1 ) - 1 ) * $ this -> perPage ; $ skip = ( int ) $ 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  " ) ; } $ objArticles = $ this -> fetchItems ( $ this -> news_archives , $ blnFeatured , ( $ limit ? : 0 ) , $ offset ) ; // Add the articles if ( $ objArticles !== null ) { $ this -> Template -> articles = $ this -> parseArticles ( $ objArticles ) ; } $ this -> Template -> archives = $ this -> news_archives ; }
Generate the module
Generate the module