Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Limit number of pages loaded in Admin

Go to End



Community Member, 57 Posts

8 March 2012 at 8:24pm

Edited: 16/03/2012 5:06am


We just migrated a Word Press news portal to SilverStripe. It has around 3-4k posts. Now this become really difficult to manage in admin section. When you login all 4k posts are loaded. Extremely slow

Can somebody suggest how can I load only last few post in admin and mark rest of them as Archive or something?

Here is my code to NewsPost.php

 * Defines the Newspost page type

class NewsPost extends BlogEntry {
	static $db = array (
     'GalleryImageWidth' => 'Int',
     'Featured' => 'Boolean',
     'UserPost' => 'Boolean',
	static $default_parent = 'NewsHolder';
	static $can_be_root = false;
	static $has_one = array(
		'Photo' => 'Image'
		//'Gallery' => 'ImageGalleryPage' 
		//'GalleryImages' => 'GalleryImage' 
	static $has_many = array (
          'GalleryImages' => 'GalleryImage'

  public function init() {

    // Note: you should use SS template require tags inside your templates 
    // instead of putting Requirements calls here.  However these are 
    // included so that our older themes still work   


	function getCMSFields() {
	$fields = parent::getCMSFields();
    $fields->addFieldsToTab("Root.Content.Main", new CheckboxField('UserPost', "Post by a Member"));
	$fields->addFieldToTab("Root.Content.Main", new CheckboxField('Featured', "Featured Post"));
	$fields->addFieldToTab("Root.Content.Images", $leadImage= new ImageField('Photo', "Upload your lead image here"));
		$leadImage->setFolderName('Uploads/' .date("Y").'/' .date("m"));
	$fields->addFieldToTab("Root.Content.Configuration", $myField= new NumericField('GalleryImageWidth', 'Image Width'));
		/*$fields-> addFieldToTab ("Root.Content.Gallery", new DropdownField("GalleryID", "Gallery", 
			DataObject::get("ImageGalleryPage")->toDropdownMap(),  'Content'));*/
		$manager = new ImageDataObjectManager(
         $this, // Controller
        'GalleryImages', // Source name
        'GalleryImage', // Source class
        'MyGalleryImage', // File name on DataObject
            'GalleryImageTitle' => 'GalleryImageTitle'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause

      $fields->addFieldToTab('Root.Content.GalleryImage', $manager); 
     return $fields;

// Function for SideBar
    function GetSidebarContent($num=3) {

      //$randomNumber = 
      $sidebarContent = DataObject::get_one("SidebarContent");

        return false;

      $contents = array();

      $contents[] =  DBField::create('Varchar', $sidebarContent->Content1);
      $contents[] =  DBField::create('Varchar', $sidebarContent->Content2);
      $contents[] =  DBField::create('Varchar', $sidebarContent->Content3);
      $contents[] =  DBField::create('Varchar', $sidebarContent->Content4);
      $contents[] =  DBField::create('Varchar', $sidebarContent->Content5);

      //return new DataObjectSet(array_rand($contents, $num));      
      return new DataObjectSet(array_slice($contents, 0, $num));   
      //return new DataObjectSet($contents);   

class NewsPost_Controller extends BlogEntry_Controller{