I'm hoping I can get a bit of direction on this, hopefully I'm just missing something obvious.
I'm trying to integrate the sortable data object functionality. I have in my
/mysite/_config
SortableDataObject::add_sortable_classes(array('Link'));
I've run the flush and the new SortOrder column was created fine.
Nothing happens on the front end though.
So I've added this to the template, /themes/mytheme/templates/Includes/Links.ss
{$Links.BeginSortableUL}
<% if Links %>
<% control Links %>
{$LI}
<% if ExternalLink %>
<a href="$ExternalLink" target="_blank">$LinkTitle</a>
<% else %>
<a href="$Link.Link">$LinkTitle</a>
<% end_if %>
<br />
{$_LI}
<% end_control %>
<% end_if %>
{$Links.EndSortableUL}
Still no changes.
So then I thought maybe I need to use add_sortable_many_many_relation, because it is.
From /mysite/Page.php
static $has_many = array(
'Blocks' => 'Block',
'Links' => 'Link'
);
$tablefield = new DataObjectManager(
$this,
'Links',
'Link',
array(
// 'LinkedPage' => 'Internal Link',
// 'ExternalLink' => 'External Link',
'LinkTitle' => 'Link Text'
),
'getCMSFields_linkPopup'
);
$fields->addFieldToTab('Root.Content.Links', $tablefield);
/mysite/LinkPage.php
<?php
class Link extends DataObject{
static $db = array(
'ExternalLink' => 'Text',
'LinkTitle' => 'Text'
);
static $has_one = array(
'Page' => 'Page',
'Link' => 'SiteTree'
);
function getCMSFields(){
return new Fieldset(
new TreeDropdownField('LinkID','Internal Link','SiteTree'),
new TextField('ExternalLink','External Link (overrides internal link)'),
new TextField('LinkTitle')
);
}
}
?>
So I change my _config.php to
SortableDataObject::add_sortable_many_many_relation('Page','Link');
or also try
SortableDataObject::add_sortable_classes(array('Link'));
SortableDataObject::add_sortable_many_many_relation('Page','Link');
as I'm not quite sure what the correct syntax is.
Then I get this error (with either of the above entries in _config.php):
Fatal error: Uncaught exception 'ReflectionException' with message 'Class does not exist' in /public_html/aston/sapphire/core/Object.php:385 Stack trace: #0 /public_html/aston/sapphire/core/Object.php(385): ReflectionClass->__construct('') #1 /public_html/aston/sapphire/core/Object.php(543): Object::uninherited_static(NULL, 'extensions') #2 /public_html/aston/dataobject_manager/code/SortableDataObject.php(19): Object::add_extension(NULL, 'SortableDataObj...') #3 /public_html/aston/dataobject_manager/code/SortableDataObject.php(52): SortableDataObject::add_sortable_class(NULL) #4 /public_html/aston/mysite/_config.php(40): SortableDataObject::add_sortable_many_many_relation('Page', 'Link') #5 /var/tmp/silverstripe-cache-home1-resolut1-public_html-aston/manifest-main(8249): require_once('/home1/resolut1...') #6 /public_html/aston/sapphire/core/ManifestBuilder.php(74): require_once('/var/tmp/silver...') #7 /home1/resolut1 in /public_html/aston/sapphire/core/Object.php on line 385
This on a otherwise blank screen.
I'm using 2.4.2, and I flush the front and db regularly.
Any help would be much appreciated!