SSbits - Home page
Site by Carbon Crayon
Submit a Post >
  • SnippetsDisable Default JavaScript Behaviours


    By default SilverStripe uses bulky and sometimes unwanted JavaScript libraries to handle form validation and AJAX page commenting features. Often you want to disable this behaviour so you can integrate your own JavaScript code. This is easily achieved with the following two lines in you site configuration file:

    Continue reading...
  • SnippetsSelect a theme using a URL parameter


    When I develop SilverStripe sites, I usually get functionality working in the default theme blackcandy before getting it working in the final templates. This way, authors can start adding content and seeing how it looks on the page, and I can get early feedback about the functionality. Also, as a developer I get to see real content in the browser early in the process. So does the designer.

    Continue reading...
  • SnippetsResizing and Manipulating Images


    You can resize images from within the template very easily. But sometimes you need to resize it and just use the URL value, something you can't do by calling the resize on the variable directly (e.g. $Image.CroppedImage(200,200)). This is how we would create a cropped resize of it and still be able to use just the URL, allowing a custom <img> tag.

    Continue reading...
  • TutorialsEmbed flash content using SWFObject



    There are numerous ways to embed flash content into your SilverStripe Website. A commonly used and very flexible method to embed flash is provided by the SWFObject script. In this snippet I'll show you how to create a custom FlashPage that will contain flash content, embedded using SWFObject.

    Continue reading...
  • TutorialsUsing jQuery for form validation



    As you may have noticed, SilverStripes built in form validation is based on Prototype and is pretty limited. It also means that even though you might be using jQuery for other things on your site, you will still need to load prototype.js and all the associated files that SilverStripe requires for it's built in JavaScript form validation.

    Continue reading...
  • TutorialsMaking a hierarchy aware templating system


    Something that has been bothering me when building larger sites with SilverStripe is that I often find myself creating new classes not to add functionality, but to just get a new template.

    You can set separate templates for different actions manually but that's not what I want in this case, I want different templates for the same action on the same class.

    After thinking about this for awhile I came up with a two part solution and the first part is to make the template choosing aware of the Sitetree hierarchy.

    Continue reading...
  • TutorialsUsing a Thickbox Modal Window with AJAX


    Thickbox is a great javascript plugin to jQuery that you can use to create modal windows within SilverStripe pages.  You can de-clutter your interfaces and re-use small snippets of common functions when you add in AJAX.  Before we begin there is a little homework:

    Continue reading...
  • SnippetsUsing a Print Stylesheet


    Often people want to be able to print webpages without all the menus and graphics and with all the content fitting correctly onto a page. To do this you need to create a separate print stylesheet. It would look something like this:

    Continue reading...
  • SnippetsClearing the Search field on click with jQuery


    As with everything, it's attention to detail that makes great sites. One thing that really bugs me is when a site has a search box with the word 'search' inside it but which does not clear it self when clicked, meaning I have to clear it before I can search. Given it can be achieved with a few lines of jQuery, it's a real surprise how many sites fail to implement this, or that still use the 'onclick' inline javascript event. 

    Continue reading...
  • TutorialsWorking with banners


    Most of the sites I work on are for corporate/business clients and there is not typically a lot of fancy motion graphics going on. I do like to ensure there is some dynamic element going on, just to provide a bit of interest and one of the simplest ways to achieve this is by some variation of the random/rotating banners scenario. Of course this could equally apply to other parts of the page, not just banner graphics.

    Continue reading...
  • SnippetsDisplaying Fields From a Set of Pages on Another Page


    Although ultimately requiring very little code, displaying data from a set of pages on another page can seem confusing for those new to SilverStripe. This example will display all of the Images from all the staff pages on our current page. This works by first returning all the staff pages to our template and cycling through each of them, drawing the Image for each one.

    Continue reading...
  • SnippetsGetting 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

    $pageIDs = $this->getDescendantIDList();
    $ObjectSet = DataObject::get(
                     "`ObjectPageID` IN (" . implode(",", $pageIDs) . ")"
    Continue reading...
  • BlogAn Example CSS Framework



    A CSS framework is a set of pre-prepared style sheets that can be used as a starting point for any project. Using a framework allows you to skip all the tedious parts of getting the basics right and lets you start working on what makes your site different from the beginning.

    Continue reading...


Site of the Month

Find SSbits on

Top Contributers

Rank Avatar Name
1 article image Aram Balakjian
2 article image wfacewomens
3 article image Daniel Hensby
4 article image Marcus Dalgren
5 article image ryduhartchas
6 article image Hamish Campbell
7 article image Ty Barho
8 article image Martijn van Nieuwenhoven
9 article image Darren-Lee
10 article image Roman Schmid

View full leaderboard