Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » display ALL dataobjects per page as default

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 839 Views
  • janulka
    Avatar
    Community Member
    80 Posts

    display ALL dataobjects per page as default Link to this post

    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!

  • Howard
    Avatar
    Community Member
    215 Posts

    Re: display ALL dataobjects per page as default Link to this post

    Just set $yourManager->setPageSize( '999' );

  • UncleCheese
    Avatar
    4085 Posts

    Re: display ALL dataobjects per page as default Link to this post

    Howard FTW!

  • wainui
    Avatar
    Community Member
    56 Posts

    Re: display ALL dataobjects per page as default Link to this post

    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');

  • pbz
    Avatar
    Community Member
    5 Posts

    Re: display ALL dataobjects per page as default Link to this post

    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.

    839 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.