Version: current

     1 <?php
     2 /**
     3  * Страница Архив новостей
     4  * Служит для вывода всех новостей сайта, независимо от места их размещения. Можно создать только одну.
     5  *
     6  */
     7 class NewsArchive extends NewsHolder {
     8
     9     function canCreate() {
    10         return (DataObject::get_one('NewsArchive')) ? false : parent::canCreate();
    11     }
    12
    13     function getCMSFields() {
    14         $fields = parent::getCMSFields();
    15         $fields->removeByName('ShowNewsFromChildHolders');
    16         $fields->removeByName('tabSubPages');
    17
    18         return $fields;
    19     }
    20
    21     /*
    22      * Получение новостей
    23      */
    24     public function Entries($start = '', $limit = '', $onlyImportant=false) {
    25         if ($start && $limit) {
    26             $limit = "{$start},{$limit}";
    27         }
    28         if ($this->SortType == 1) {
    29             $sort = 'DESC';
    30         } else {
    31             $sort = 'ASC';
    32         }
    33         $filter = "`Status` LIKE '%Published%'";
    34         if ($onlyImportant) {
    35             $filter .= " AND Important = 1";
    36         }
    37         $res = DataObject::get("NewsEntry", $filter, "`NewsEntry`.Date {$sort}, `NewsEntry`.ID {$sort}", "", "$limit");
    38         return $res;
    39     }
    40 }
    41
    42 class NewsArchive_Controller extends NewsHolder_Controller {
    43
    44 }
    45

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -