I have ImageDataObjectManager, with images, all working nice.
But DOM displays 10 objects per page in CMS as default, how do I change this particular ImageDOM to display all items per page as default?
Thank you!
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
I have ImageDataObjectManager, with images, all working nice.
But DOM displays 10 objects per page in CMS as default, how do I change this particular ImageDOM to display all items per page as default?
Thank you!
Just set $yourManager->setPageSize( '999' );
Howard FTW!
hmmm... not sure if that works (does it uncle?) didnt seem to for me.. although I noticed the code is there in the DOM.php
I managed to do the same using code below.. not sure if correct way.
$manager->setPerPageMap('All');
$manager->setPageSize('All');
Here's a more complete solution.
// Show All by default
$manager->per_page = "9999";
$manager->setPageSize(9999);
if(isset($_REQUEST['ctf']['RelationName'])) $manager->setPageSize($_REQUEST['ctf']['RelationName']['per_page']);
Be sure to replace RelationName with the actual name of the relation in question.
Explanation:
Only using setPageSize (line 3) means the drop down no longer works, so after setting it to default you set it based on the request value (line 4). Setting per_page (line 1) is necessary for the dropdown to have All selected in the dropdown by default. It is necessary to make a small hack of changing the decleration of per_page from protected to public in DataObjectManager.php for this last bit to work. Everything else works fine without the hack.