Home

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!

Tutorial: Creating a Simple Contact Form

In this tutorial we create a simple contact form which sends an email using a custom template. This type of form can be extended to create complex sets of fields and processing actions.

Read More >>

Snippet: Dynamically Generating a Dropdown List

If you want to create a drop down list (or option set) dynamically, for example from a set of pages or DataObjects, you can use the DataObject::get() call along with the function toDropdownMap() to generate it like so:

Read More >>

Snippet: Create a Field in 'Page' but not it's Decendents

This snippet allow you to add a field only to a page of type 'Page' and not those pages which extend Page.

Read More >>

Snippet: Create a Permission Code

Ever wanted to add an extra permission code so that when you add permissions to a group you can create a custom option? Here's how it's done; Simply add this code to your Page_Controller class as well as adding "implements PermissionProvider" on the end of the class definition like so:

That will create two new permission codes: 'USER' and 'SUPERUSER', so you can then call permission::check('USER') anywhere in your code to see if the current user is in a group with USER permissions.

 

Read More >>

Snippet: getting objects from multiple child pages

When you want to create a DataObjectSet encompasing objects from all the current pages children you can do something like this:

The first line creates an array of the ID's from all, with the current page and any descendant page ID's.

The second line onwards then gets all Objects that have an ObjectPageID that is either the current page's ID, or any child page of the current page.

You can then add the usual filter, join or limit clauses to the DataObject::get call.

Read More >>

Blog: 10 Super Useful SilverStripe Documentation Pages

Since I started learning SilverStripe I have come across a number of very useful documentation pages which were not very easy to find (at least not as easy as they could be). So here is a list of 10 official documentation pages which I always find myself referring back to.

Read More >>

Tutorial: Custom Login Form with Group Based Redirection

In this tutorial we are going to setup a custom login form which redirects the user based on the group they are in. A tree dropdown is added to each group in the CMS to allow easy page selection as well as a checkbox to override this link and redirect to the admin area.

An example usage for this would be a company that has numerous clients each with their own client area. This technique would allow them to login and reach their respective areas without ever knowing who the other clients are or having to deal with finding links to get them there.

Read More >>

Snippet: Check to see if a widget area has any widgets

If you want to check that a WidgetArea actually has widgets, and only display it if it has, you can add this function to your Page_Controller (where widgetBarID is the name of your widgetArea + ID):

Then in your template file, MyPage.ss you can use HasWidgets to check whether the WidgetArea should be rendered:

Read More >>

Blog: jQuery Expanding Menu Plugin

Having looked around for a simple expanding menu and finding nothing I liked, I decided to make my own using the fantastic jQuery javascript framework.

Here is the demo of what I came up with. It pretty much does what it say's on the tin, but hopefully you will find it elegant and easy to implement.

Read More >>

Snippet: Create an 'Edit this Page' link

For some sites you may want your client to be able to click a link on a particlar page and be taken strait to that page in the admin area. Here's what a link that does just that would look like:

If you wanted this to only show up when a user is logged in you could use the CurrentMember call to check. So it would look like this:

You could also take this a step further and write a function in your page controller to check whether the current user has permission to access the CMS using Permission::check('CMS_ACCESS_CMSMain') call.

Read More >>
| 1 3 4 5 6 7 |