Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Sort Order Not Working

Go to End


Media Contour

Community Member, 33 Posts

18 February 2012 at 2:12pm

Edited: 21/02/2012 7:36am

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 %>