7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » SortableDataObject not working
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 858 Views |
-
SortableDataObject not working

25 March 2010 at 7:54am Last edited: 25 March 2010 7:55am
Hi,
For some reason I am getting the following error when I try to rebuild the db with SortableDataObject::add_sortable_class('Link'); in my _config file: [Notice] Undefined variable: _SESSIONThese are my files:
<?php
class Link extends DataObject
{
static $db = array (
'AltText' => 'Varchar(50)',
'TitleText' => 'Varchar(50)',
'Description' => 'HTMLText', // HTMLText does not convert html tags to plan text
'LinkUrl' => 'Varchar(50)'
);static $has_one = array (
'LinksPage' => 'LinksPage',
'LinkImage' => 'Image'
);public function getDOMThumbnail()
{return $this->LinkImage()->CroppedImage(50,50);}function getCMSFields()
{
return new FieldSet(
new ImageField('LinkImage'),
new TextField('AltText'),
new TextField('TitleText'),
new TextField('Description'),
new TextField('LinkUrl'));
}
}
?><?php
class LinksPage extends Page
{
static $has_many = array (
'Links' => 'Link'
);public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this,
'Links',
'Link',
array(
'DOMThumbnail' => 'Thumbnail',
'AltText' => 'AltText',
'TitleText' => 'TitleText',
'Description' => 'Link description',
'LinkUrl' => 'Url of link'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.Links", $manager);
return $fields;
}} // END of LinksPage
class LinksPage_Controller extends Page_Controller
{
} // END of LinksPage_Controller
?>Any ideas?
Sam -
Re: SortableDataObject not working

25 March 2010 at 9:13am
You've got whitespace somewhere. Check all your PHP files and make sure there isn't any content being sent to the browser. You're closing your PHP tags.. you should remove those to prevent errors like this.
-
Re: SortableDataObject not working

25 March 2010 at 1:02pm
Thanks Uncle Cheese!
Yup, there was white space at the end of the Link.php file that was creating the error. Removed it, now the sortable object works.
So, are you saying to use the opening php tag "<?php" but not the closing one "?>" as a general rule of thumb in my SS php files?Sam
-
Re: SortableDataObject not working

25 March 2010 at 1:36pm
Yeah, in an MVC framework, you should never have to close a PHP tag.
-
Re: SortableDataObject not working

25 March 2010 at 4:33pm
I found this forum thread when looking for how to sort something in SS. I've now found the http://doc.silverstripe.org/doku.php?id=modules:sortabledataobject page but can't actually see where to download the module from. I've looked in the modules pages but can't see it there. Where do I get it from? Thanks!
-
Re: SortableDataObject not working

25 March 2010 at 4:37pm
Ah never mind, I found it's contained within this extremely useful module which the forum topic is all about
| 858 Views | ||
|
Page:
1
|
Go to Top |

