SilverStripe 2.4 Module Extension, Themes, and Widgets: Beginner's Guide

SilverStripe 2.4 Module Extension, Themes, and Widgets: Beginner's Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • The first and only book that focuses on extending SilverStripe sites
  • Step-by-step instructions covering everything you need to know for getting started with making the most of the core functionality, developing modules, creating themes, and adding widgets
  • Build a fun, real-world example application without breaking a sweat
  • Reviewed by Sigurd Magnusson, co-founder of SilverStripe, and Ingo Schommer, development manager at SilverStripe
  • For more recent updates to the code, please visit the author's own repository at Updated Code Here

Book Details

Language : English
Paperback : 368 pages [ 235mm x 191mm ]
Release Date : May 2011
ISBN : 184951500X
ISBN 13 : 9781849515009
Author(s) : Philipp Krenn
Topics and Technologies : All Books, CMS and eCommerce, Beginner's Guides, Content Management (CMS), Open Source

Table of Contents

Chapter 1: Principles and Concepts
Chapter 2: Customizing the Layout
Chapter 3: Getting "Control" of Your System
Chapter 4: Storing and Retrieving Information
Chapter 5: Customizing Your Installation
Chapter 6: Adding Some Spice with Widgets and Short Codes
Chapter 7: Advancing Further with Inheritance and Modules
Chapter 8: Introducing Forms
Chapter 9: Taking Forms a Step Further
Chapter 10: Targeting the Whole World
Pop Quiz Answers
  • Chapter 1: Principles and Concepts
    • Why SilverStripe
      • CMS and framework
      • Openness and interoperability
      • Getting your job done
    • The file structure
      • assets/
      • cms/
      • googlesitemaps/
      • mysite/
      • sapphire/
      • themes/
    • SilverStripe's ecosystem
      • The company behind SilverStripe
      • Documentation
        • User help
        • Developer documentation wiki
        • API documentation
      • Community
        • Forum
        • IRC chat
        • Development mailing list
        • Bug tracker
        • Twitter
    • Summary
    • Chapter 2: Customizing the Layout
      • Templates and themes
        • Switching between themes
      • Time for action – change the default theme
        • Getting more themes
      • Template engine
        • Another template engine?
      • Taking a look at BlackCandy
        • CSS
          • editor.css
          • layout.css, form.css, and typography.css
          • ie6.css
        • Templates
          • Learning the very basics
          • Starting to use templates
      • Time for action – using site title and slogan
        • Layout
        • Includes
      • Page control overview
        • More placeholders
        • Casting placeholders
          • Security
          • Date formatting
        • Users
        • Control structures
          • Handle with care
          • Embedding and linking files
          • Comments and base tag
          • Conditional statements
          • Control statements
        • BlackCandy revisited
      • Creating our own theme
      • Time for action – files and folders for a new theme
        • Basic layout
        • File themes/bar/templates/
      • Time for action – the base page
        • File themes/bar/templates/Layout/
      • Time for action – the layout page
        • The includes:,, and
      • Time for action – the includes
        • What's next?
      • Not finding the #*?~^ error?
      • Adding interactive features
      • Time for action – let users share our page on Facebook and Twitter
      • Taking care of search engines
        • Semantic HTML
        • Meaningful URLs
        • Broken links
        • Duplicate content
        • Meta tags
        • Validation
        • Sitemap
      • Summary
      • Chapter 3: Getting "Control" of Your System
        • Model View Controller (MVC)
          • Why the big fuss?
          • View: Presenting your content
          • Model: Managing your data
          • Controller: Providing your logic
          • Taking a look at an example
        • Structure of a Page
          • Page.php: Your initial start
          • Convention over configuration revisited
          • Extending classes is key
          • Coding conventions
        • Using the Controller
          • Path constants
          • The default page class
          • Setting up CSS
            • Including CSS files
        • Time for action – adding a print style
          • Combining CSS files
      • Time for action – reducing HTTP requests for CSS files
        • Adding custom CSS
        • Taking care of Internet Explorer
      • Time for action – add your own head tags
        • Setting up JavaScript
          • Including Google Analytics
      • Time for action – adding custom JavaScript in the Controller
        • Blocking files
      • Time for action – removing JavaScript in the Controller
        • Where to include CSS and JavaScript
      • Coding conventions
        • Coding
          • Indentation
          • Curly braces
          • Check before looping
          • Keeping the Controller clean
          • Comments
        • Methods
          • Static methods
          • Action handler methods
          • Template methods
          • Object methods
        • Variables
        • Element order
      • Spam protecting e-mail addresses
        • Controller
        • Template
        • CMS
      • URL variables and parameters
        • Activating changes
        • Debugging
          • Template
          • Controller
          • Request
          • Debug
        • Performance
        • Debugging the code
      • Adding an Intro page
      • Summary
        • Chapter 4: Storing and Retrieving Information
          • DBPlumber
            • Your new best friend: DBPlumber
          • Time for action – installing DBPlumber
          • From a database's point of view
          • Adding custom fields to a page
          • Time for action – putting content into the database
          • More data types and their form fields
          • Global custom fields
            • Configuration
            • Code
              • Database fields
              • Accessing properties in the CMS
            • Template
            • Synchronize the database and you're ready to go
          • How database values are fetched
            • Pushing
            • Pulling
          • Taking the Model further
            • Removing unused Page types
            • Showing the Page type in the Page Tree
              • Adding an image
              • Don't change the file ending
              • Using constants
            • More SiteTree magic
            • Cleaning up content fields
            • Setting a meta title prefix
          • Managing relations
          • Time for action – linking pages together
            • Definition
            • Adding relationships to the CMS
            • Using it in the template
            • Complex relationships
          • Queries
            • Security
              • Casting
              • Escaping
            • Debugging queries
          • Visible or invisible?
            • In the Model
            • In the Controller
          • Summary
          • Chapter 5: Customizing Your Installation
            • Configuration in general
              • Default settings
            • Environment
              • dev
              • test
              • live
              • Defining a development server
              • Server-wide configurations
            • Logging
              • Logging information
                • Error levels
                • SilverStripe and PHP errors
                • Website errors
              • Notification of errors
              • Securing the logs
            • Templates
            • Security
            • Customizing the CMS
              • Removing tabs
              • Rebranding the CMS
              • Loading add-ons
            • WYSIWYG
              • Switching to HTML
              • Removing buttons
              • Adding buttons
              • Configuring plugins
              • Options
            • Comments and spam
              • Math questions
              • Akismet
              • Other measures
            • E-mail
            • Miscellaneous settings
              • Accessing and advertising content
              • Allowing file extensions
              • Customizing Breadcrumbs
              • Image quality
              • JavaScript validators
              • Defines
            • Time for action – building our own configuration
            • Managing your code
              • Version control system
              • VCS basics
              • Using Git in your project
                • Manual upgrade of core files
                • Automatic upgrade of core files
                • Contributing back
            • Summary
            • Chapter 6: Adding Some Spice with Widgets and Short Codes
              • Widget or short code?
              • Creating our own widget
              • Time for action – embracing Facebook
                • Widgets in general
                • Facebook graph API
                • Connecting pages and widgets
                  • $SideBar
                  • What about the intro page?
                • Facebook feed widget
                  • Facebook output
                  • The logic in general
                  • Taking a look at the details
                  • The template
                  • The other template
                • More widgets
              • Text parser
              • Time for action – doing it "right"
              • Caching
                • Partial caching
                • Static publisher
                • Static exporter
                • Restful service
              • Partial caching
                • Example
              • Time for action – caching
                • Configuration
                • Controller
                • Template
                • General considerations
              • More on partial caching
              • Carefully test your cache settings
              • Cache directory
              • Performance gains
                • Server-side
                • Client-side
            • Creating our own short code
            • Time for action – how to find us
              • What do we want to achieve?
              • Configuration
              • Model
                • General composition
                • Example-specific code
              • Template
              • Common pitfalls
              • Go forth and build your own
            • Summary
              • Chapter 7: Advancing Further with Inheritance and Modules
                • Enhancing the intro page
                • Time for action – adding the required modules
                • Time for action – extending the backend functionality
                  • Introducing the DataObject class
                    • SiteTree
                    • DataObject
                    • DataObjectDecorator
                  • Making DataObjects sortable
                  • Adding our DataObject to the intro page
                    • Storing required information in the database
                    • Providing a field in the CMS
                • Time for action – integrating our changes into the frontend
                  • Working with images
                  • Image functions
                    • Images in the Controller
                    • Images in the View
                • Image galleries
                • Time for action – creating our own image gallery in the CMS
                  • A single gallery image
                  • Image gallery container
                • Time for action – our image gallery in the frontend
                  • Image gallery template
                • Transforming our code into a module
                  • Creating a module
                  • Required changes
                • Time for action – adapting the module
                • Time for action - integrating the module into our page
                  • Contribute back to the community
                • Summary
                • Chapter 8: Introducing Forms
                  • Building a contact form
                  • Time for action – creating a basic contact form
                    • The backend
                    • Including our form in the frontend
                    • Creating an e-mail template
                    • The frontend
                    • The e-mail template
                    • The Model
                    • The Controller
                      • Setting up the form
                      • Processing the input
                      • Sending the e-mail
                      • Handling the success page
                      • Convention of method names
                  • Renting a table
                    • Going "abstract"
                  • Time for action – extending our form with abstraction
                    • The backend
                    • Changes in the template file
                    • Update the e-mail template
                    • Abstract
                      • Model
                      • Controller
                    • Implementation
                  • Adding client-side validation
                    • Default client-side validation
                    • Enhanced client-side validation
                  • Time for action – using jQuery's Validation plugin on the contact page
                    • jQuery's Validation plugin
                • Time for action – using jQuery's Validation plugin on the rent page
                  • Setting up the Datepicker
                • Should you add JavaScript to the Controller?
                • Tougher server-side validation
                • Time for action – better server-side validation
                • Summary
                  • Chapter 9: Taking Forms a Step Further
                    • Searching our pages
                    • Time for action – adding search functionality to our page
                      • The Controller part of the code
                      • The View part of the code
                    • Customizing forms even further
                      • Overwriting the global template
                      • Handcrafting forms with SilverStripe
                    • Saving data to the database
                    • Time for action – extending the member card form
                      • The Model part of the code
                      • Setting up the fields
                        • New arguments for TextField
                        • OptionsetField
                        • CheckboxField
                        • DateField options
                      • Checking for invalid data and duplicate e-mail addresses
                      • Saving a new entry to the database
                    • Field types overview
                      • ConfirmedPasswordField
                      • HiddenField
                      • More
                    • Checking the e-mail address for uniqueness
                    • Time for action – checking the e-mail's uniqueness with Ajax
                    • Doing more with sessions
                    • Time for action – using the session in forms
                    • How to store members in the database
                    • Summary
                    • Chapter 10: Targeting the Whole World
                      • Globalization in general
                      • Globalization in the CMS
                      • Time for action – configuring the CMS for globalization
                      • Globalization in the code
                        • Localizing and internationalizing the templates
                          • Starting our globalization efforts
                      • Time for action – globalizing the intro page
                        • Generating locale files
                      • Localizing and internationalizing the PHP code
                    • Time for action – translating the rent form
                      • Localizing and internationalizing JavaScript
                    • Time for action – translating the rent form's JavaScript
                    • Getting the right content
                    • Time for action – switching the locale
                    • Where to go from here
                      • More modules
                      • Adding more ideas and features to your page
                    • Summary
                      • Pop Quiz Answers
                        • Chapter 2, Customizing the Layout
                          • Pop quiz—placeholders
                          • Pop quiz—say hello to the current user
                        • Chapter 3, Getting "Control" of Your System
                          • Pop quiz—duplication or not?
                          • Pop quiz—basic principles
                        • Chapter 5, Customizing Your Installation
                          • Pop quiz—environment types
                        • Chapter 6, Adding Some Spice with Widgets and Short Codes
                          • Pop quiz—too many options?
                        • Chapter 7, Advancing Further with Inheritance and Modules
                          • Pop quiz—SiteTree, DataObject, or DataObjectDecorator
                        • Chapter 8, Introducing Forms
                          • Pop quiz—true or false
                        • Chapter 9, Taking Forms a Step Further
                          • Pop quiz—advanced forms
                        • Chapter 11, Targeting the Whole World
                          • Pop quiz—if / when should you globalize

                        Philipp Krenn

                        Philipp Krenn lives in Vienna, Austria and studies software engineering. Besides being a student, he also works as a freelance IT trainer and web developer (mostly using SilverStripe, but also some Drupal, CakePHP, and Smarty). Philipp started using SilverStripe in 2007 while he was one of the students at the Google Summer of Code improving the project. While kicking off the effort to support multiple databases (besides MySQL), he got a good insight into the inner workings of the project. Building on top of that, he became an expert in developing web applications with SilverStripe.
                        Sorry, we don't have any reviews for this title yet.

                        Code Downloads

                        Download the code and support files for this book.

                        Submit Errata

                        Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                        - 2 submitted: last submission 08 Nov 2012

                        Errata type: Code | Page number: 223

                        The code
                        new HTMLEditorField(
                        Text after sending the message'
                        should be
                        new HTMLEditorField(
                        'Text after sending the message'


                        Errata type: Technical | Page number: 226

                        The e-mail template is named '' on this page, and on later pages, but in the code on page 224 the template name used is just 'Email'.
                        The template is called in the first half of the chapter, but on page 240 ("Update the e-mail template") it is renamed since its use is broadened. That's why the name is different in the final code sample. In the downloadable code the template is called ''.


                        Sample chapters

                        You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                        Frequently bought together

                        SilverStripe 2.4 Module Extension, Themes, and Widgets: Beginner's Guide +    ASP.NET MVC 2 Cookbook =
                        50% Off
                        the second eBook
                        Price for both: £24.65

                        Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                        What you will learn from this book

                        • Convert general HTML and CSS files into SilverStripe templates to create magnificent themes
                        • Create and extend different page types, both in terms of look and functionality
                        • Enable your content editor to efficiently interact with your system, for instance, adding new images to the image gallery
                        • Store user input in the database or send it via e-mail
                        • Translate your page and internationalize it – think about the various date formats, for instance
                        • Implement common tasks, including search functionality, integration of Google Maps or Facebook, and much more
                        • Set up a toolset for common tasks (search functionality, Google Maps, and Facebook)
                        • Develop powerful server-side scripts while catering for security and performance

                        In Detail

                        HTML, CSS, JavaScript, PHP, databases, frameworks, CMS, and many other fast-evolving technologies make up modern web-development. How can you effectively create stunning results without being limited by the ease of your tools? That's where SilverStripe CMS comes into play.

                        SilverStripe, with its simple and intuitive design, is easy to work with and offers numerous customization opportunities. But understanding the options available and getting hands-on with the development techniques is not a piece of cake and certainly not a delightful experience if you're relying on tutorials and documentation available online.

                        Silverstripe 2.4 Module Extension, Themes, and Widgets: Beginner's Guide takes you through designing catchy and flexible templates, adding powerful features effortlessly, integrating everything into an intuitive backend for easy administration in a simple way, and implementing nifty features with minimal effort. From the most basic to complex forms, from simple to sophisticated pages, you'll learn how to get the most out of your SilverStripe application. SilverStripe keeps everything nice and simple, but if you need to, you can extend and customize every part of it. Graphic examples illustrate the general principle of operation, gradually introducing the finer details needed to get professional results. Common requirements such as image galleries, site search, and more can be reused or extended to fulfill your needs.

                        The author's experience in designing and developing SilverStripe projects enables him to share insights on creating professional web applications in a clear and friendly way.

                        You will start off with creating your own templates – covering the general layout, while also taking search engine optimization into consideration. Next, you will look at the logic driving your web application, and the database. Using these basic concepts, you will start building more advanced features. These include the integration of Google Maps, Twitter and Facebook, image galleries, the handling of user-supplied information, your own full-text search, and more. Finally, you'll even translate and internationalize your project. All of this can be easily achieved with SilverStripe.

                        All of this and quite a bit more is covered by Silverstripe 2.4 Module Extension, Themes and Widgets: Beginner's Guide. Besides general principles, the focus is on reusable code – getting your project started in no time.

                        A practical guide for extending SilverStripe applications with ease, describing real-life examples right from the start


                        Designed as a Beginner's Guide, this book takes basic ideas step-by-step to a higher level, and builds fully featured applications. Besides the raw programming, you will also be confronted with different approaches, showing you which solution is "right". The example project built throughout this book is also used for a live project, based on the needs of a real business. You will start with an idea for a project. From the initial design, via the basic implementation, to the final polishing – every single step is highlighted.

                        Who this book is for

                        If you are a SilverStripe developer and want to learn the nooks and crannies of developing fully-featured SilverStripe web applications with module extensions, themes, and widgets, then this book is for you. Building upon your knowledge of PHP, HTML, and CSS, this book will take you to the next level of SilverStripe development. The book assumes you have basic experience with SilverStripe.

                        Code Download and Errata
                        Packt Anytime, Anywhere
                        Register Books
                        Print Upgrades
                        eBook Downloads
                        Video Support
                        Contact Us
                        Awards Voting Nominations Previous Winners
                        Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                        Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software