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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Tutorials seem broken


Go to End
Reply

13 Posts   2353 Views

Avatar
one_life

11 December 2009 at 6:55am Community Member, 8 Posts

Hi All,

New to SilverStripe, and I am going through the awesome tutorials, but I am really stuck.

I am on the form turorial and the news tutorial, but I can't seem to get 2 things working.
1. My form for the poll will not work when trying to post the data to the DB, I am getting this error:

[User Error] Uncaught ReflectionException: Class text does not exist
POST /latique/home/BrowserPollForm

Line 89 in /Applications/MAMP/htdocs/latique/sapphire/core/Object.php

Source

80     * @param string $class the class name
81     * @param mixed $arguments,... arguments to pass to the constructor
82     * @return Object
83     */
84    public static function create() {
85       $args = func_get_args();
86       $class = self::getCustomClass(array_shift($args));
87       
88       if(version_compare(PHP_VERSION, '5.1.3', '>=')) {
89          $reflector = new ReflectionClass($class);
90          return $reflector->newInstanceArgs($args);
91       } else {
92          // we're using a PHP install that doesn't support ReflectionClass->newInstanceArgs()
93          
94          $args = $args + array_fill(0, 9, null);
95          return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8]);

Note: Line 89 highlighted red.

And the RSS feed doesn't work either - keeps telling me that RSS is not allowed on the news page class, but I copied the tutorial exactly.
I am running this on MAMP OS X 10.6.2, PHP 5, MySql 5.0.41. Am I doing something wrong? I have re-written this part of the tutorial about 10 times and nothing gives. This is my first try at SilverStripe, and although I really like everything I am seeing, I am not sure I can go on using it if I am unable to follow the tutorials. I really want to use it though, this looks like the best CMS I have ever seen.

Any advice would be appreciated.

Avatar
Willr

11 December 2009 at 8:42am Forum Moderator, 5511 Posts

And the RSS feed doesn't work either - keeps telling me that RSS is not allowed on the news page class, but I copied the tutorial exactly.

Ah I don't think the tutorials have been updated with the new $allowed_actions option. To get that to work just add this code at the top of your page type

static $allowed_actions = array(
'rss'
);

For your poll code do you might attaching your code?

Avatar
one_life

11 December 2009 at 11:14am Community Member, 8 Posts

Hey, thanks for the reply Willr :)

Here is my poll code (homepage class)

class HomePage_Controller extends Page_Controller{
   
   // Poll
   function BrowserPollForm(){
   
      // create fields
      $fields = new FieldSet(
         new TextField('Name'),
         new OptionsetField('Browser','Your Favorite Browser', array(
            'Firefox' => 'Firefox',
            'Internet Explorer' => 'Internet Explorer',
            'Safari' => 'Safari',
            'Opera' => 'Opera',
            'Lynx' => 'Lynx'
         ))
      );
      
      // create actions
      $actions = new FieldSet(
         new FormAction('doBrowserPoll', 'Submit')
      );
      
      // validator
      $validator = new RequiredFields('Name','Browser');
      
      // return form
      return new Form($this, 'BrowserPollForm', $fields, $actions, $validator);
   }
   
   // process poll
   function doBrowserPoll($data, $form){
      $submission = new BrowserPollSubmission();
      $form->saveInto($submission);
      $submission->write();
      
      Session::set('BrowserPollVoted', TRUE);
      
      Director::redirectBack();
   }
   
   // show poll results
   function BrowserPollResults(){
      $submissions = DataObject::get('BrowserPollSubmission');
      $total = $submissions->count();
      
      $doSet = new DataObjectSet();
      foreach($submissions->groupBy('Browser') as $browser => $data){
         $percentage = (int) ($data->count() / $total * 100);
         $record = array(
            'Browser' => $browser,
            'Percentage' => $percentage
         );
         
         $doset->push(new ArrayData($record));
      }
      
      return $doset;
   }
}

?>

thanks in advance for any advice,

Avatar
one_life

11 December 2009 at 11:19am Community Member, 8 Posts

no dice on the RSS either. getting this error:
Action 'rss' isn't allowed on class ArticleHolder_Controller"

<?
/*
   ArticleHolder - allows ArticlePages to go inside it
*/

class ArticleHolder extends Page{
   static $db                = array();
   static $has_one          = array();
   static $allowed_children    = array('ArticlePage');
   static $icon = "themes/tutorial/images/treeicons/news";
   static $allowed_actions = array('rss');
   
   /* RSS FEED */
   function rss() {
    $rss = new RSSFeed($this->Children(), $this->Link(), "The coolest news around");
    $rss->outputToBrowser();
   }
}

class ArticleHolder_Controller extends Page_Controller{
   function init() {
    RSSFeed::linkToFeed($this->Link() . "rss");   
    parent::init();
   }
}

?>

Avatar
Willr

11 December 2009 at 11:21am Forum Moderator, 5511 Posts

You need to add the $allowed_actions to the controller - not the model as the controller deals with the URL requests.

Avatar
one_life

11 December 2009 at 11:23am Community Member, 8 Posts

hahaha, thanks. I feel lazy now because that was so obvious. Thanks.

Avatar
one_life

11 December 2009 at 11:35am Community Member, 8 Posts

Any red flags on my BrowserPoll code?

Avatar
Willr

11 December 2009 at 8:06pm Forum Moderator, 5511 Posts

Could you post the full backtrace of your error. The actual line that is red in the error is misleading the *actual* cause of the error is usually traced to one of the options in the backtrace.

Go to Top