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?
_config.php
SortableDataObject::add_sortable_classes(array('CatalogProduct'));
CatalogProduct.php
class CatalogProduct extends Page {
static $belongs_many_many = array('HomePage' => 'HomePage');
}
class CatalogProduct_Controller extends Page_Controller {}
HomePage.php
class HomePage extends Page {
public static $many_many = array('CarouselProducts' => 'CatalogProduct');
function getCMSFields() {
$fields = parent::getCMSFields();
$carousel = new ManyManyDataObjectManager(
$this,
'CarouselProducts',
'CatalogProduct',
array('Title' => 'Title'),
'getCMSFields_forPopup'
);
$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() {
parent::init();
}
}
HomePage.ss
<% control CarouselProducts %>
<a href="$Link">$Title</a>
<% end_control %>