Welcome to SSbits! Here you will find tutorials, code snippets and other web related goodies all geared towards the fantastic SilverStripe CMS. Our aim is to help people get up to speed with the great features of SilverStripe even quicker than we did and hopefully provide some inspiration along the way!

Blog: New SSbits site launches on October 1st!

As you may have noticed, things have been a little quiet around here recently. Thankfully there is a good reason for that; I have been re-developing the site! The new site will have some great new features to help deliver an all around better user experience as well as paving the way for new types of content. The new site will be launching on the 1st of October (all going to plan) with a week of new content to get things going!

In the meantime, follow us on Twitter or Join our Facebook page!


Snippet: A _config.php Cheatsheet

If your anything like me, you've probably found yourself going through your previous sites looking for that line of code to put in your _config.php file. Well, now you nolonger need to, simply bookmark this page and return to it any time you need to add a line to your config! And if I've missed out anything leave a comment and I'll make sure it gets added :)


Snippet: Customise buttons in userforms module

Submitted by Barry Keenan

I wanted more control over the styling of submit buttons in the userforms module. The standard button use either an <input> tag or a <button> tag. I needed an extra span so I could style the button super prettyà la:


Snippet: Customize the Redirect after a successful Member Login

When a Member logs in to /Security/login without a ?BackURL= specified, they are always redirected back to the form with a success message and form without any fields.  While this works great to keep the code/form tight, it is a less than ideal use experience.  Modifying this behavior is a little tricky as much of the controller and rendering actions are fixed in the Security class.  This is further complicated by the use of Director::redirect calls that set response headers when the login form is processed.  I find by overriding the form and replacing it with the excellent useCustomClass call works well.

The Problem: Base /Security/login form redirects to itself on success, always tagging ?BackURL=/home looks sort of messy across your site.

The Solution: Make the base MemberLoginForm redirect somewhere useful on success.



Tutorial: 2.4 - Using Short Codes to embed a YouTube video

Submitted by Dan Hensby

Silverstripe 2.4 has introduced shortcodes to the CMS editor. Simply, the CMS user can now add short BBCode style code to the editor area and it can then be replaced using a predefined function. For example [link id=23] could be replaces by the link to Page with ID 23. In fact that is exactly how internal links created in the links sidebar work in 2.4, preventing them from breaking when URLs change.

The aim of this tutorial

The aim of this tutorial is to allow the CMS user to enter the short code:

[YouTube id=3UTu6lV8ppY]


[YouTube id=3UTu6lV8ppY]A video about SilverStripe[/YouTube]

we will also allow them to add more custom attributes. We will then use this to embed a YouTube video automatically for the user.



Snippet: Controlling the order of CSS includes

Submitted by Matt Clegg

Usually CSS developers are lazy -even more so than php developers! What usually happens is (as you can see in firebug) that styles get redefined by sub CSS files depeding on a parent containing div -so it's important to include these CSS files in the correct order, otherwise they will be overwritten incorrectly and the style wont appear as you wish.

Your probably already using Requirements::themedCSS but there is another function called Requirements::insertHeadTags. This is great for including custom style sheets because you can call it AFTER your usuall CSS. An example would be something like;



Tutorial: 2.4 - Working with SiteConfig

One of the great new features of 2.4 is the introduction of a Site Config page. This allows you to put all of those fields which are not page related, such as The sites title, root access permissions and even the current theme. The SiteConfig class is simply a dataobject and so can easily be extended to include fields, relationships and functions which you can then access from anywhere in your site.

Accessing items in your SiteConfig is as easy as preceding each item with $SiteConfig. For example this would display the Title field:


Snippet: Automatically ?flush when in 'dev' mode

Submitted by Dan Hensby

Often when doing development work on a website - and particularly the templates - it can be a pain having to remember to add ?flush to the end of the URL to make sure all of your changes have come through.

I'm sure that all of us have had that "d'oh" moment when we have spent too much time wondering why our changes weren't working, only to find a simple flush fixed it.

If you have set up a domain in your set_dev_servers array or added Director::set_environment_type('dev') to your _config.php file then you can also add:


Blog: Review: The SilverStripe Book

Submitted by Hilary Boyce

I’ve recently been working with Silverstripe, which was relatively new to me, so I got the book. This post is a review of the book “Silverstripe. The Complete Guide to CMS Development” by Ingo Schommer and Steven Broschart; I wanted to share my thoughts about this title.

When I say I’m working with SilverStripe, I mostly get blank looks. Few people have heard of it, even amongst PHP developers; so firstly what is SilverStripe?


Snippet: Using other systems together with Silverstripe

Submitted by Yuri Goul

Silverstripe uses mod_rewrite to catch all calls to your website in the form of urls and route them to sapphire/main.php. This behavior is implemented with the rules in your .htaccess file in the root of your site. This can become a problem when you want to use other systems together with Silverstripe because you simply can not reach the url of those other systems.

An example: if your want to use phplists as a newsletter system, it is usually installed under yoursite.com/lists. However, under normal circumstances you can not have your visitors reach yoursite.com/lists when using Silverstripe because it is rerouted to sapphire/main.php?url=lists.


1 2 3 4 5 6 7 |