Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » 500 Internal Server Error

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

Page: 1
Go to End
Author Topic: 660 Views
  • Stef87
    Avatar
    Community Member
    66 Posts

    500 Internal Server Error Link to this post

    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"

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: 500 Internal Server Error Link to this post

    You have a typo: publiv function getThumb()

    Cheers, Martine

    660 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.