Version: current

     1 <?php
     2 /**
     3  * Snippets have the following generic variables, that can be used in generic templates:
     4  *
     5  * $Title
     6  * $URL
     7  * $Date
     8  * $ID
     9  * $EditLink
    10  * $DeleteLink
    11  */
    12
    13
    14 class RecentPages extends DashboardPlugin {
    15     static $position = "snippet";
    16     static $sort = 0;
    17     static $title = "Recent pages";
    18     static $link = "admin/cms/";
    19     static $limit_count = 10;
    20     static $caption = "Часто редактируемые страницы.";
    21     static $null_message = 'Нет страниц';
    22     static $edit_link = 'admin/cms/show';
    23
    24     public function GenericSnippetList() {
    25         $output = new DataObjectSet();
    26
    27         $items = DataObject::get("SiteTree", NULL, "`LastEdited` DESC", NULL, "0,".self::$limit_count);
    28
    29         if($items) {
    30             foreach($items as $item) {
    31                 $date = new Date('Date');
    32                 $date->setValue($item->LastEdited);
    33
    34                 $output->push(new ArrayData(array(
    35                     'URL'           => Director::baseURL().$item->URLSegment,
    36                     'Title'         => $item->Title,
    37                     'Date'          => $date,
    38                     'ID'            => $item->ID,
    39                     'EditLink'      => self::$edit_link.'/'.$item->ID
    40                 )));
    41             }
    42         }
    43         return $output;
    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. -