Home

xeraa edited this page Nov 25, 2011 · 16 revisions
Clone this wiki locally

We tried to keep our book SilverStripe 2.4 Module Extension, Themes, and Widgets: Beginner's Guide as accurate as possible, but sometimes mistakes creep in. This page lists the errors submitted by our astute readers. If you've found a new error, please file it under https://github.com/xeraa/silverstripe-book/issues

Page numbers are from the printed version of the book.

There's also a list of references (sample chapters, reviews,...) and a trivia section of the book.

Errors

Page Original Corrected Finder (Date)
100 $fields->addFieldToTab( 'Root.Content.BasicInfo', new HTMLEditorField('OpeningHours', 'Opening hours of the bar', 'Content')); $fields->addFieldToTab( 'Root.Content.Main', new HTMLEditorField('OpeningHours', 'Opening hours of the bar', 'Content')); Frank Mullenger (2011-06-03)
131 As we've already said, any errors of this layer will go to logs/php.log. As we've already said, any errors of this layer will go to logs/ss.log. Frank Mullenger (2011-06-03)
153 if(!isset($post['from']['id']) II !isset($post['id'] II !isset($post['message'])){ Note: Please replace II with pipes, but markdown can't handle them in tables! if(!isset($post['from']['id']) II !isset($post['id']) II !isset($post['message'])){ Note: Please replace II with pipes, but markdown can't handle them in tables! Greg Kerstin (2011-07-27)
223 new HTMLEditorField('SubmitText', Text after sending the message') new HTMLEditorField('SubmitText', 'Text after sending the message') Anonym (2011-11-25)
224 $validator = new RequiredFields('email', 'comment', 'firstName', 'surname'); $validator = new RequiredFields('Email', 'Comment', 'FirstName', 'Surname'); micschk (2011-08-26)

Typos

Page Original Corrected Finder (Date)
61 All we have to do is defining two classes, one for the Model and one for the Controller. All we have to do is define two classes, one for the Model and one for the Controller. Frank Mullenger (2011-06-03)
88 But you don't need to type it in manually, you can simply copy it from the book's code repository, provided at http://www.packtpub.com/support. But you don't need to type it in manually, you can simply copy it from the book's code repository, provided at https://github.com/xeraa/silverstripe-book. Frank Mullenger (2011-06-03)
121 Better be safe than sorry. Better to be safe than sorry. Frank Mullenger (2011-06-03)
125 The default database is MySQL and this is the one we will use this book. The default database is MySQL and this is the one we will use in this book. Frank Mullenger (2011-06-03)
125 If you were using German texts in your CMS you'd set this to de_DE instead of en_US. If you were using German text in your CMS you'd set this to de_DE instead of en_US. Frank Mullenger (2011-06-03)
139 Append ?showspam==1 to the URL of a page with comments to review messages marked as spam after enabling this option: Append ?showspam=1 to the URL of a page with comments to review messages marked as spam after enabling this option: Frank Mullenger (2011-06-03)
175 Assume you installation is located in Webserver/silverstripe6/ and PHP has not been configured to specifically use a different temporary directory: Assume your installation is located in Webserver/silverstripe6/ and PHP has not been configured to specifically use a different temporary directory: Frank Mullenger (2011-06-03)
186 While this has already helped us getting pretty far, there are limits. While this has already helped us in getting pretty far, there are limits. Frank Mullenger (2011-06-03)
241 Therefore, the templating engine will try to load themes/bar/templates/Email.ss instead of Page.ss in the same folder as the general layout file. Therefore, the templating engine will try to load themes/bar/templates/Emailer.ss instead of Page.ss in the same folder as the general layout file. Frank Mullenger (2011-06-03)
247 You need to tell jQuery (already included by mysite/code/Page.ss) to use the Validation plugin on our form: You need to tell jQuery (already included by mysite/code/Page.php) to use the Validation plugin on our form: Philipp Krenn (2011-05-29)
316 However this is deprecated in HTML5 and should instead be added to the <html> tag instead, which we did back in chapter two: However this is deprecated in HTML5 and should be added to the <html> tag instead, which we did back in chapter two: Frank Mullenger (2011-06-03)
318 Add the following code to themes/bar/templates/Layout/Page.ss and themes/bar/templates/Layout/GalleryPage.ss—heres' the relevant section with the changes highlighted: Add the following code to themes/bar/templates/Layout/Page.ss and themes/bar/templates/Layout/GalleryPage.sshere's the relevant section with the changes highlighted: Frank Mullenger (2011-06-03)

Thirdparty Changes

Facebook API

Due to a Facebook API change (https://developers.facebook.com/blog/post/509/) the Facebook widget described in the book is broken. This will now require a valid access_token to fetch content from walls and posts.

The updated, working code looks like this - only the function Feeds() requires changes:

/**
 * Fetch the messages from Facebook and make them available to the template.
 * The feed includes both your own posts and the ones from others. We are however only interested in our own posts, so we'll fetch some more and throw the others away.
 * Taking five more might not be sufficient, but we'll assume it's enough for our scenario.
 *
 * @return DataObjectSet Array containing all relevant fields.
 */
public function Feeds(){

    /**
     * URL for fetchning the information, convert the returned JSON into an array.
     * It is required to use an access_token which in turn mandates https.
     */
    if(!defined('FACEBOOK_ACCESS_TOKEN')){
        user_error('Missing Facebook access token - please get one and add it to your mysite/_config.php: define("FACEBOOK_ACCESS_TOKEN", "&lt;your token&gt;");', E_USER_WARNING);
        return;
    }
    $url = 'https://graph.facebook.com/' . $this->Identifier . '/feed?limit=' . ($this->Limit + 5) . '&access_token=' . FACEBOOK_ACCESS_TOKEN;
    $facebook = json_decode(file_get_contents($url), true);

    /**
     * Make sure we received some content, create a warning in case of an error.
     */
    if(empty($facebook) || !isset($facebook['data'])){
        user_error('Facebook message error or API changed', E_USER_WARNING);
        return;
    }

    /**
     * Iterate over all messages and only fetch as many as needed.
     */
    $feeds = new DataObjectSet();
    $count = 0;
    foreach($facebook['data'] as $post){
        if($count >= $this->Limit){
            break;
        }

        /**
         * If it isn't a post, but an event for example: continue with the next entry.
         */
        if(!isset($post['from']['id']) || !isset($post['message'])){
            continue;
        }

        /**
         * If the post is from the user itself and not someone else, add the message and date to our feeds array.
         */
        if(strpos($this->Identifier, $post['from']['id']) === 0){
            $posted = date_parse($post['created_time']);
            $feeds->push(new ArrayData(array(
                'Message' => DBField::create('Text', $post['message']),
                'Posted' => DBField::create(
                    'SS_Datetime',
                    $posted['year'] . '-' . $posted['month'] . '-' . $posted['day'] . ' ' . $posted['hour'] . ':' . $posted['minute'] . ':' . $posted['second']
                ),
            )));
            $count++;
        }
    }
    return $feeds;
}

Note that you must get a Facebook access_token, which you'll need to add to mysite/_config.php: define("FACEBOOK_ACCESS_TOKEN", "<your token>");