Information, tutorials, code tips and how tos for programming the SilverStripe CMS

SilverStripe is a free open source content management system that is coded in PHP and supports MySQL, Microsoft SQL Server and Postgres as database backends. It contains the Sapphire model-view-controller framework and is extremely extendable. There are a number of modules, themes and widgets abailable and it is easily customisable. The admin interface is slick and can also be customised with additional tabs and fields depending on the page types.

Be sure to check out the online documentation and The latter is full of all sorts of useful tips and tricks and is worth spending time looking through after reading the docs.

Post sort order: Post Date (Newest First) | Post Date (Oldest First) | Alphabetical | Date Updated

New Zealand Government websites to switch to Silverstripe

Posted Feb. 08, 2013 in SilverStripe

New Zealand Government websites will switch to Silverstripe, the free, open-source CMS/framework from Wellington company Silverstripe under an "all-of-government" contract.

Replacing the TinyMCE paste plugin in SilverStripe 2.4

Posted Dec. 12, 2011 in SilverStripe

The SilverStripe 2.4.x CMS uses TinyMCE as the WYSIWYG HTML editor and comes with the Paste plugin for reformatting pasted text. Unfortunately the version that comes with SilverStripe 2.4 is fairly out of date and doesn't handle pasting very well in webkit based browsers (or at least for me on Chrome on the Mac).

Prefix img src assets with a leading slash in SilverStripe

Posted Jun. 15, 2011 in SilverStripe

When inserting an image into the TinyMCE HTML editor in SilverStripe it doesn't prefix the src attribute of the img tag with a leading slash leaving it like e.g. src="assets/images/myimage.jpg". This is acceptable because it writes out a <base> tag into the document <head> so these relative urls are made into absolute URLs using the href in the base tag. However, as I have found, some bots ignore the base tag and are unable to grab the images correctly. This post shows how to modify your base page class in SilverStripe to prefix assets with a leading slash.

Allow style attribute in image tags in TinyMCE in SilverStripe

Posted Jun. 13, 2011 in SilverStripe

The SilverStripe CMS html editor uses TinyMCE which strips out style attributes for the image tag by default. Fortunately it is very easy to prevent this from happening if you want to be able to assign styles directly in the HTML to an <img> tag. Whether or not you should actually add inline styles is a different post altogether :)

Book Review: SilverStripe 2.4 - Module Extension, Themes and Widgets

Posted Jun. 07, 2011 in SilverStripe

SilverStripe 2.4 - Module Extension, Themes and Widgets is a just released book by Philipp Krenn and published by Packt Publishing. The title of the book is slightly mis-leading but only because it gives an excellent overview of SilverStripe as a whole, not just dealing with modules, themes and widgets.

Populate defaults dynamically with SilverStripe

Posted Jun. 05, 2011 in SilverStripe

SilverStripe allows default values to be set for fields on data objects using the static $defaults property but this cannot be populated with dynamic values, such as using date() or rand(). Instead use the populateDefaults() function.

Move the SilverStripe navigator to the top of page

Posted Apr. 29, 2011 in SilverStripe -

SilverStripe is a PHP based CMS system. When logged into the admin part of the site there's a navigator bar that appears fixed at the bottom of the page allowing the editor to easily edit a page in the CMS, or toggle between the draft and published version of the site. This post shows how to relocate the SilverStripe navigator bar to the top of the page.

Change the default sort order for files and images in SilverStripe

Posted Apr. 06, 2011 in SilverStripe

SilverStripe's File, Folder and Image objects have a default sort of 'Name', 'Sort' and 'Name' respectively, but if you are also using Uncle Cheese's DataObjectManager the sort order will change to the 'SortOrder' field. Unless you've been sorting these yourself they're going to appear in the ImageField control in a more or less random order, which isn't idea. This post shows the solution.

Making the Tree Tools sticky in SilverStripe

Posted Mar. 25, 2011 in Offsite Articles and SilverStripe

I use SilverStripe for a number of my websites and find the tree tools in the the site tree area annoying how it scrolls out of view when scrolling through a large set of pages. This post shows some screenshots of the issue and solution, and links through to the solution at SSbits.

Move the SilverStripe delete buttons away from the save buttons

Posted Feb. 18, 2011 in SilverStripe

This post shows how to relocate the "Unpublish" and "Delete from the draft site" buttons away from the "Save" and "Save and Publish" buttons in a SilverStripe installation without modifying the core SilverStripe files.

Set TinyMCE options with SilverStripe

Posted Jan. 05, 2011 in PHP and SilverStripe

The SilverStripe/Sapphire CMS/Framework uses TinyMCE as the HTML editor. Normally to set configuration options for TinyMCE you would do it in your own tinyMCE.init() call, but in SilverStripe this is called dynamically in PHP in core Sapphire code. There's a simple way to add configuration options as shown in this post.

SilverStripe and PHP version requirements

Posted Dec. 29, 2010 in PHP and SilverStripe

This post looks at the minimum PHP version requirements for SilverStripe. I will update this page as new versions are released and I upgrade the various SilverStripe websites I manage, noting any issues I experience.

"calls without an existing one..." rendering in SilverStripe output

Posted Nov. 13, 2010 in SilverStripe

When moving a SilverStripe site from one server to a differently configured one we came across an odd bug where some content from the SSViewer.php file would render in the output the first time that template was requested but not on subsequent requests.

SilverStripe: Escape raw values for a SQL query

Posted Aug. 09, 2010 in Quick Tips and SilverStripe

This is just quick little post for self reference to show how to escape values which go into a raw SQL query in SilverStripe; I find myself never being able to remember this and having to always look it up.

SilverStripe InPast solution for bug

Posted Aug. 03, 2010 in SilverStripe

SilverStripe date fields have a number of functions that can be used on them in templates; one of these is the InPast function which unfortunately appears to have a bug in it (at least in SS 2.4.0 and 2.4.1). This post looks at the issue and the workaround I created.

SilverStripe Quick Tip: Enable Akismet spam filter

Posted May. 23, 2010 in Quick Tips and SilverStripe

Any page on a SilverStripe website can have comments on it and can easily be passed through the Akismet spam filtering service to check if it is spammy. This quick tip shows how to enable Akismet in SilverStripe after you've got an API key.

SilverStripe Quick Tip: Enable comment moderation

Posted May. 19, 2010 in Quick Tips and SilverStripe

By default SilverStripe comments do not require moderation i.e. all comments are automatically approved and displayed on the site. This quick tip shows how to enable moderation in a SilverStripe install so the moderator has to approve all comments before they are visible.

SilverStripe Quick Tip: Comments in Templates

Posted May. 11, 2010 in Quick Tips and SilverStripe

It's funny how we programmers don't tend to read documentation (well I often don't tend to anyway - at least not cover to cover) and turn to search engines to find the answers to our questions. When looking for something quite different from what this post is about I stumbled across the SilverStripe templates documentation page and discovered how to put comments into a SilverStripe template that will be stripped out of the published site. So here's a quick tip to point it out to those of you who use SilverStripe and may not already know this.

SilverStripe cache directory

Posted Mar. 13, 2010 in SilverStripe -

SilverStripe by default creates a directory for caching the site manifest etc by using the PHP function getSysTempDir(). It is possible to locate this directory elsewhere by simply creating a directory called silverstripe-cache in the website's root directory, or at any other location by setting the TEMP_FOLDER constant.

How to put text right next to a SilverStripe template placeholder

Posted Mar. 06, 2010 in SilverStripe

I needed to put some text directly next to a placeholder in a SilverStripe template and couldn't find the answer in the online documentation or the SilverStripe book, but perhaps I missed it. In any case, I worked it out from a user comment so show here how to do it.

Solution for "Error saving content" when saving an error page in SilverStripe

Posted Feb. 25, 2010 in SilverStripe

I was getting the error message "Error saving content" when publishing an error page in the SilverStripe CMS and couldn't work out why. The changes were being displayed in the front end so the error message seemed kind of odd.

How to log into SilverStripe if you've lost the login details

Posted Feb. 24, 2010 in SilverStripe

If you have lost the admin login details for a SilverStripe installation and sending an email to reset the password is not working, there is a default admin account that can be enabled. After logging in, reset the regular administrator's details and then remove the temporary login as shown in this post.

Style the #SilverStripeNavigatorMessage in SilverStripe

Posted Feb. 23, 2010 in SilverStripe

When logged into the SilverStripe CMS admin or viewing a SilverStripe on a development site there's a box with a red background that is positioned absolutely showing whether this is the published or the draft version of the site. This post shows how to override the styles for this box.

.htaccess condition to prevent missing CSS, JS, image urls being parsed by SilverStripe

Posted Feb. 21, 2010 in Apache and SilverStripe

The default .htaccess file for SilverStripe runs all URLs that do not belong to actual files on the filesystem through the Sapphire framework. This means that if a request is made for a CSS file that does not exist, for example, it will be run through SilverStripe/Sapphire, which is not really necessary.

Files and permissions when installing SilverStripe

Posted Feb. 20, 2010 in SilverStripe

When you open up your web browser to a SilverStripe install for the first time there's an installation process that needs to be run. This requires several permissions to be set correctly when running on a *nix based host so this post has the commands needed to quickly make these permissions correct, and then switch them back and clean up the redundant files afterwards.

The SilverStripe book and Amazon delivery estimations

Posted Feb. 19, 2010 in SilverStripe

I ordered the SilverStripe book "SilverStripe: The Complete Guide to CMS Development" from on Friday last week and received it yesterday morning. I'll review it properly once I've finished reading it cover to cover (probably by the end of the weekend) but for the moment wanted to have a look at Amazon's delivery estimations.

What files can be deleted after installing SilverStripe?

Posted Feb. 18, 2010 in SilverStripe

After installing SilverStripe there are a whole bunch of files in the site's root directory which are no longer needed and can be deleted. This post lists which files are safe to delete.

Different home page and sub pages with SilverStripe

Posted Feb. 16, 2010 in SilverStripe

The SilverStripe CMS makes it very easy to have a slightly different layouts between pages by creating another page type and using $Layout with different layout templates. I did this for the Fabco Ltd website which is a small website with a larger main image on the homepage and a smaller version of this image on the subpages; in all other respects the templates are the same.

Upcoming SilverStripe Posts

Posted Feb. 15, 2010 in SilverStripe

If you follow my blog you will have seen in the last three days a few posts about the SilverStripe CMS system. I've just started using it and am creating a big portal site with it along with converting some of my existing websites and creating some new sites with SS.

SilverStripe admin stopped working

Posted Feb. 13, 2010 in SilverStripe -

When I was setting up a new template for a SilverStripe based website I was suddenly no longer able to access the admin area. I got the login form but after logging in I kept getting a page not found error when the web browser was trying to access/Security/Security/LoginForm

I've started using the SilverStripe PHP CMS framework

Posted Feb. 12, 2010 in SilverStripe

During the course of this week I've been looking at a number of different PHP CMS systems and frameworks, compared with developing an in-house one, for creating a huge new motorhome travel portal. After some consideration I've decided on using SilverStripe.