7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » [RESOLVED] Set Default Behaviour of 'Results Per Page'
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 710 Views |
-
[RESOLVED] Set Default Behaviour of 'Results Per Page'

16 August 2011 at 9:42am
Hey All. Was hoping for a bit of help again.
I have the folowing code defining a page which works great:
Speakerpage.php
<?php
class SpeakersPage extends SiteTree {
public static $db = array(
'RightContent' => 'HTMLText',
);
public static $many_many = array(
'Speakers' => 'Speaker',
'KeyNoteSpeakers' => 'Speaker',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab( 'Root.Content.Speakers', new ManyManyDataObjectManager(
$this,
'Speakers',
'Speaker'
));$fields->addFieldToTab( 'Root.Content.KeyNoteSpeakers', new ManyManyDataObjectManager(
$this,
'KeyNoteSpeakers',
'Speaker'
));return $fields;
}
}
...Having looked around I can see that the functions I'm looking for to change the default behaviour of the 'results per page' on my cms are
$myDOM->setPerPageMap();
$myDOM->setPageSize();Problem is I'm not sure as per the above code where to put these functions?
I've tried below but this causes the site to break? Any suggestions of what I am doing wrong?
<?php
class SpeakersPage extends SiteTree {
public static $db = array(
'RightContent' => 'HTMLText',
);
public static $many_many = array(
'Speakers' => 'Speaker',
'KeyNoteSpeakers' => 'Speaker',
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab( 'Root.Content.Speakers', new ManyManyDataObjectManager(
$this,
'Speakers',
'Speaker'
));$fields->addFieldToTab( 'Root.Content.KeyNoteSpeakers', new ManyManyDataObjectManager(
$this,
'KeyNoteSpeakers',
'Speaker'
));$fields->setPageSize(50);
return $fields;
}
}
... -
Re: [RESOLVED] Set Default Behaviour of 'Results Per Page'

17 August 2011 at 1:58am
You run them against a DataObjectManager instance..
$yourDOM->setPageSize(50);
-
Re: [RESOLVED] Set Default Behaviour of 'Results Per Page'

17 August 2011 at 2:06am
Thanks for the reply unclleCheese. I tried that as per the code above
$fields->setPageSize(50);
and it didn't work. Getting an 'error on the cms everytime I try to access the page. Is it because I have two doms running on that page with the same name?
-
Re: [RESOLVED] Set Default Behaviour of 'Results Per Page'

17 August 2011 at 4:56am
$fields is a FieldSet object, not a DataObjectManager.
$fields->addFieldToTab("Root.Content....", $dom = new DataObjectManager(.....));
$dom->setPageSize(50);
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com -
Re: [RESOLVED] Set Default Behaviour of 'Results Per Page'

17 August 2011 at 5:25am
Thanks sir. That did the trick. I just assumed $fields was a variable for the dom. Need to look into that one.
| 710 Views | ||
|
Page:
1
|
Go to Top |

