I have got several "Project"-Pages and want to show some of them in a custom order on my "Home"-Page.
Therefore I use the SortableGridField-Module in combination with the GridFieldConfig_RelationEditor:
Home-Class
public static $has_many = array(
'Highlights' => 'Project'
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$conf=GridFieldConfig_RelationEditor::create();
$conf->addComponent(new GridFieldSortableRows('HighlightSortOrder'));
$gridField = new GridField('Highlights', 'Highlight Projects', $this->Highlights(), $conf);
$fields->addFieldToTab("Root.Main", $gridField);
return $fields;
}
Project-Class
public static $db = array(
'HighlightSortOrder'=>'Int'
);
public static $default_sort = 'HighlightSortOrder';
It seems to work sometimes, but just after using the preview-Button in the admin-area.
There is also the problem, that all "Project"-Pages which are linked as Highlights, are now Subpages of the "Homepage" in the Sitetree.
Have you got an idea how to fix these problems or is there a better approach?
Thanks!