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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

500 Internal Server Error


Go to End


2 Posts   1225 Views

Avatar
Stef87

Community Member, 66 Posts

3 August 2012 at 12:27am

Edited: 03/08/2012 1:22am

Hi

I'm pretty new to SilverStripe and I have a problem. I was following this tutorial http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/ and have got as far as the StaffPage page type bit. I am doing it slightly differently but I have encountered a 500 internal server error. I am completely clueless about how to solve this so I would really appreciate some help.

//The StaffMember class in the tutorial but I called it Article
<?php

class Article extends DataObject
{
//db fields
static $db = array (
'Headline' => 'Text',
'DatePublished' => 'Date',
);

//relationships
static $has_one = array (
'ArticlePage' => 'ArticlePage',
'Photo' => 'Image'
);

//fields for DOM table
static $summary_fields = array (
'Thumb' => 'Photo',
'Headline' => 'Headline'
);

public function getCMSFields()
{
return new FieldSet(
new TextField('Headline'),
new DateField('DatePublished'),
new ImageField('Photo')
);
}

publiv function getThumb()
{
if($this->PhotoID)
return $this->Photo()->CMSThumbnail();
else
return '(No Image)';
}
}
?>

//The StaffPage page but I called it ArticlePage

<?php

class ArticlePage extends Page
{
static $has_many = array(
'Articles' => 'Article'
);

public function getCMSFields()
{
$fields = parent::getCMSFields();

$manager = new DataObjectManager(
$this,
'Articles',
'Article'
);
$fields->addFieldToTab("Root.Content.Articles", $manager);

return $fields;
}
}

class ArticlePage_Controller extends Page_Controller
{

}
?>

Thanks

Edit: I figured out that it was simply a problem with my code. Lesson to me to always reread the code. I am still getting an error even though the pages are appearing that says refused to set unsafe header "Connection"

Avatar
martimiz

Forum Moderator, 1391 Posts

4 August 2012 at 6:34am

You have a typo: publiv function getThumb() :-)

Cheers, Martine