SilverStripe
eBook - ePub

SilverStripe

The Complete Guide to CMS Development

Ingo Schommer, Steven Broschart, Julian Seidenberg

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

SilverStripe

The Complete Guide to CMS Development

Ingo Schommer, Steven Broschart, Julian Seidenberg

Book details
Book preview
Table of contents
Citations

About This Book

This is the Official Guide on the award-winning SilverStripe programming framework, authored by the creators of the open source CMS.

SilverStripe is a robust and flexible website content management system (CMS) tightly integrated with an application framework. It is open source and embraces modern system architecture and agile development methodologies. Intermediate developers can implement powerful websites and web-applications quickly and customize them to their individual needs. The award-winning PHP5/MySQL-based system saves not only time and nerves for techies, but also features a straightforward interface which is a joy to use for non-technical content-authors.

This Guide helps you to:

  • Get started with SilverStripe: Learn the architecture and usability principles that underpin SilverStripe's modern approach. Then go through the technical requirements, the installation process, and useful tools for your daily work.
  • Learn the CMS: Practical examples show you how to use the CMS as a content author, and how to manage content, images, documents, and forms without technical knowledge. Administrators learn how to set up permissions and security groups.
  • Develop a custom application: Use MVC and other modern design patterns to create well-structured, object-oriented PHP code and concise template markup. Let the authors walk you through creating an interactive recruitment website as practical example project.
  • Extend through clean code and modules: Understand how SilverStripe is built on modularity and how this empowers you to build plugins and core extensions in an elegant, maintainable fashion.
  • Use SilverStripe professionally: In-depth topics on internationalization, security, unit testing, caching, multi-page forms, and web services APIs ensure that you can build world-class websites.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is SilverStripe an online PDF/ePUB?
Yes, you can access SilverStripe by Ingo Schommer, Steven Broschart, Julian Seidenberg in PDF and/or ePUB format, as well as other popular books in Design & Webdesign. We have over one million books available in our catalogue for you to explore.

Information

Publisher
Wiley
Year
2010
ISBN
9780470711477
Topic
Design
Subtopic
Webdesign
Edition
1
1
Introduction
At itā€™s heart, the role of a content management system (CMS) is to make it easier to publish content to websites and intranets. It may be used to allow the owner of a one-person company to update his or her website without needing a website developer or learning HTML skills. Or, in a multinational company, it might allow a skilled web team across various cities to manage a complex assortment of updates to products, services, promotions, and news in multiple languages. Either way, it automates various tasks, and makes building a website more efficient and reliable.
Countless products are available based on such a promise, however, all of varying sophistication, histories, programming languages, and geographical dominance. The decision-makers and developers involved in selecting a CMS work in fast-paced environments and are creatures of habit: They have personal favorites to solve the challenges their job provides. Why go through the trouble of trying a new CMS?

1.1 Why SilverStripe?

One thing up front: SilverStripe is not the answer to all problems that you might face throughout the development of a website or web application. No software is ever a silver bullet for every situation. You must determine selection criteria based on your needs, skills, budgets, and timeframes, and select the most relevant tool based on those criteria. That said, SilverStripe is intended to be both used out-of-the-box and for major customization. This makes it particularly interesting when building websites - because everyone seems to relish having a unique set of needs in terms of design, information architecture, content, features, integration with other systems, business policies, and so on.
The following pages list some major benefits of SilverStripe, and describe how it stands out in a crowded CMS market. We acknowledge that the information here is concise, but this will help you refer back to an overview even when youā€™re familiar with SilverStripe. We try to keep things brief here; the rest of the book will substantiate the claims made, as you begin to build stuff using the software.

1.1.1 An Application and a Framework

SilverStripe is really two products in one: The SilverStripe CMS and the Sapphire Framework. There are plenty of CMS applications and quite a few programming frameworks in the marketplace; however, SilverStripe is very rare in that it tightly weaves the two concepts together.
You will need to read the whole book to understand entirely the value of this unity, but the value is much greater than the sum of its parts. In other words, the CMS has plenty of good things about it, as does Sapphire. However, with them joined so closely, their collective value is multiplied. The closeness of the two concepts is possible because Sapphire and the CMS were created in tandem, by the same people.

1.1.2 CMS for Content Authors and Framework for Developers

One fundamental reason for SilverStripe being divided into two sections is to honor the needs of two quite separate types of people who use the software. The CMS backend is designed to allow non-technical users to update web pages, images, links, moderate blog comments, and so on. This is the area where content authors do their content management, and anything technical is strictly kept out of sight for the sake of good usability.
The framework is used to build the underlying website, and isnā€™t for content authors. You ā€˜useā€™ the framework by actually writing HTML, CSS, JavaScript, and object-oriented PHP code. The framework enables beginning PHP programmers to achieve quite powerful things, by following recipes and tutorials as shown in this book and elsewhere. However, the framework is targeted at savvy PHP programmers. For them, Sapphire allows much more creative freedom in building complex websites quickly and robustly.
Many other CMS products donā€™t have such a separation. In other words, in many systems the CMS user interface is shared by content authors and developers, which typically makes the interface too complicated for itā€™s primary users: the content authors. In some systems, developers perform their work mainly through a graphical configuration interface, which is usually more limiting than raw programming. A graphical interface to accommodate sophisticated needs for developers would require a bewildering set of options, which would add complexity and bloat the software, when the idea in question is likely to be far more efficiently expressed as a few lines of code.
So, this separation in SilverStripe means that the CMS backend can be designed for non-technical users, and the framework can confidently concentrate on being suitable to technically-minded web developers (see Figure 1.1 for an overview of the SilverStripe system).
Figure 1.1 SilverStripe system overview.
002

1.1.3 Clear Separation of Concerns

As we begin to suggest above, a core principle in SilverStripe is the separation of concerns. In this introduction, we use that term loosely to mean organizing the software into all sorts of logical divisions. You will be familiar with how HTML and CSS separate the concerns of markup and presentation, and that JavaScript is used to allow for the concern of behavior and interaction on a web page. This structure provides many benefits such as enabling reuse: change a single style in a CSS file, and so long as youā€™ve stuck to best practices in your HTML, styles throughout the whole website will update, saving time and maintaining consistency.
SilverStripe follows this principle: Update an isolated area of the system that deals with a particular function, and it produces logical, robust, and application-wide changes. Without this architectural principle, changing a feature of your website means changing a few lines of code here, a few lines of code there, and finding that each step of the way upsets unrelated parts of your website. This domino effect suddenly turns a small change into a major coding and testing fiasco. SilverStripeā€™s architecture therefore helps to keep code changes proportionate to the effort needed to implement them. However, like the HTML, CSS, and JavaScript example, this reward is only given to those who carefully architect their SilverStripe application to its best practices.
Letā€™s highlight a few examples relating to this principle:
ā€¢ Avoid repitition with the Sapphire framework. Sapphire supports the concept of writing the logic of your website once. For instance, if your website deals with selling T-shirts, you define that a T-shirt has an attribute ā€˜colorā€™ in one place in your code. You donā€™t have to write redundant code elsewhere to explain that T-shirts have colors; the template, CMS, and even the database will automatically be updated based on your single declaration. This principle is commonly called Donā€™t repeat yourself (DRY ).
ā€¢ No need to change database schema manually. This important point is hinted at above: SilverStripe will inspect your code for the tables and fields it needs, and update the schema accordingly. This makes keeping your database schema in sync with your PHP code a beautiful thing.
ā€¢ Separates the PHP logic into the Model and the Controller. Youā€™re probably familiar with separating PHP logic from HTML templates, but SilverStripe goes one step further. This is a very integral part of Sapphire, so letā€™s pause for a moment to investigate this in the following box.
Model View Controller as a central concept
The Model View Controller (MVC) concept is one of many design patterns that have been identified as good programming architecture. A design pattern is essentially a structured way to document the solution to a specific problem in computer science, a term made popular by the ā€˜Gang of Fourā€™ in their book Design Patterns: Elements of Reusable Object-Oriented Software (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, published by Addison-Wesley). The three parts, Model, View, and Controller, describe the main roles of any application built with SilverStripe:
ā€¢ The Model is responsible for maintaining the state in the application. Itā€™s basically data: Some of it might be transient and only live within a web request, whereas other data might be permanently stored in a database. You can think of the Model as essentially the database schema you have for a website. We elaborate on this simplistic definition in later chapters.
ā€¢ A View displays data thatā€™s collected from the Model, usually through a template on a website or application frontend. One Model might have many Views: The list of forum users on your website might have a ā€˜public viewā€™ and a ā€˜backend management interface viewā€™. In both of these views, the used Model logic would be the same: The separation into different roles avoids code duplication and clarifies responsibilities.
ā€¢ The Controller manages the layer in between the Model and View, and passes data between them. Itā€™s the ā€˜glueā€™ of an application. It might take a new forum submission from a View, and tell the model to store it in the database. Although the actual input form is rendered in the View, the Controller is responsible for processing it. The Controller, for instance, would ensure that the submitter can post to this forum, and might send out emails to moderators or people subscribed to the forum. To clarify, the Model should not be responsible for such logic, and instead just store the data once the Controller has figured out what needs storing and how. Using the example here, separating the Model and Controller shows how you can have different form processing logic (multiple Controllers) making reuse of the Model.
All three roles work closely together. Itā€™s just important to understand what goes where on a conceptual and practical level. If that sounds a bit too abstract for you at the moment, donā€™t despair. MVC is a central concept in SilverStripe, and weā€™ve dedicated an in-depth explanation to it in Chapter 3, Section 3.2, ā€˜MVC - Model View Controllerā€™.
ā€¢ Object Relational Mapper. The PHP code throughout SilverStripe is heavily object-oriented rather than procedural code, and this architecture extends to how you access the database. This maintains a unified approach to processing data both in and out of your database: you deal with objects rather than flipping constantly between arrays, methods, objects, SQL syntax, and so on. This lessens the lines of code used to create, remove, update, and delete data in your database, and improves readability. It also marries the database schema more closely to your PHP code, thereby lessening the risk that these are out of sync. The concept is explained in Chapter 3, Section 3.3, ā€˜ORM - Object Relational Mappingā€™ in more depth.
ā€¢ A very flexible data-model. Because of the ORM and the MVC patterns, SilverStripe is able to consume quite complex data structures. You might have all sorts of different ā€˜typesā€™ of pages, each with different fields. Then you might add products, members, product reviews, coupon codes, and all sorts of other objects to your website. All of this data needs to be stored in your database, managed in the CMS, and presented on your public website. SilverStripe allows you to have a complex entity model, full of relationships, while ensuring the structure and data granularity is elegant.
ā€¢ HTML, CSS, and JavaScript. Being the lingua franca of the web, SilverStripe respects that competent website developers need to have control over and separate their website into these three languages. In other words: SilverStripe doesnā€™t make you add CSS into your HTML. Nor does it prevent you from intelligently using JavaScript to progressively enhance your website with extra functionality. It stays out of your hair - as a developer, you can craft these files and incorporate them into your project in an elegant fashion. This provides for fantastic flexibility in your markup, therefore providing freedom in visual design.
ā€¢ Simple template language. The ā€˜Viewā€™ mentioned in the MVC explanation above means that SilverStripe templates donā€™t contain logic. More than simply insisting pedantically that the Controller instead should contain this logic - it means that the templates deliberately resemble standard HTML syntax and that they can be created and edited by people without PHP skills. This lets you unleash your zealous HTML- and CSS-skilled designer on SilverStripe templates. Compared to other templating languages, SilverStripeā€™s seems overly simplistic. But you might come to appreciate the benefit of this in the same way you appreciate extracting your CSS out of your HTML: When you need to change something you have only one place to look, making changes easy and encouraging consistency.
ā€¢ Class inheritance as a means of customization. This is really a topic for a later chapter in the book. But itā€™s important, and so we whet your appetite with a preview. If you have the concept of a ā€˜Productā€™ in your application, how do you customize that to make some ā€˜Productsā€™ a ā€˜Bookā€™, which might require an Author field? Extensions like this are fundamental to any CMS software package. SilverStripe uses the natural capabilities of an object-oriented language to extend Products into Books. This is nothing special in any object-oriented language, and all MVC frameworks do this, but itā€™s rare for a CMS to get out of your way and just let you use these natural features of object-oriented code.
ā€¢ Clean file system structure. SilverStripeā€™s file and folder structure is neatly organized in several ways. The core application lives in a couple of top-level folders. All your project-specific changes go into your own top-level folders, providing convenient separation from the core package. Files containing code are named specifically based on the PHP classes they define. This means a lot of files, but also makes the role of each file specific and deliberate. Template files follow similar naming conventions, which makes SilverStripe websites portable: You can just move files and folders from one installation to another and be confident about what functionality in the application youā€™re shifting.
ā€¢ Modules, themes, and widgets. The core functionality of SilverStripe can be extended by modules (for example ā€˜forumā€™ functionality), themes (changing the visual appearance of your website), and widgets (small features you can add to a page). We will build all of these types throughout this book. Extensions allow the core to be...

Table of contents