Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Sort Order Not Working

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: 626 Views
  • Media Contour
    Community Member
    33 Posts

    Sort Order Not Working Link to this post

    Please reference code below.

    I'm able to sort the CatalogProducts in the admin but it does not get rendered in the HomePage by the sort order. I'm not sure what the problem is as the sort order gets saved in the admin. What is it sorting by? Why is it sorting by that?




    class CatalogProduct extends Page {
       static $belongs_many_many = array('HomePage' => 'HomePage');

    class CatalogProduct_Controller extends Page_Controller {}


    class HomePage extends Page {
       public static $many_many = array('CarouselProducts' => 'CatalogProduct');
       function getCMSFields() {
          $fields = parent::getCMSFields();
          $carousel = new ManyManyDataObjectManager(
             array('Title' => 'Title'),
          $fields->addFieldToTab('Root.Content.CarouselProducts', new LiteralField('Carousel Products Break', '<br />'));
          $fields->addFieldToTab('Root.Content.CarouselProducts', new LabelField('Carousel Products Label', 'Carousel Products'));
          $fields->addFieldToTab('Root.Content.CarouselProducts', $carousel);
          return $fields;

    class HomePage_Controller extends Page_Controller {
       public static $allowed_actions = array ();

       public function init() {


    <% control CarouselProducts %>
       <a href="$Link">$Title</a>
    <% end_control %>

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.