SSbits - Home page
Site by Carbon Crayon
Submit a Post >
  • TutorialsAdding a CMS action



    If like me you cannot figure out how on earth to use the updateCMSActions() function in a decorator and you also can't get the getCMSActions() function to find your custom method inside the controller then here is a way to make it work, which will allow you to create custom actions and buttons to trigger those actions within the CMS.

    Continue reading...
  • SnippetsSpice up Your CMS Sitetree


    SSBsitetreeicons So you have created your own page types, but they all look the same in your CMS site tree. Time to make them more recognizable! This is quite easy, but it can make your site tree a lot more attractive. Continue reading...
  • SnippetsHow to access your admin account when you've forgotten the password


    I managed to forget my admin password and found quite a few ways to unlock an SS install. I originally thought about poking around the database and changing the hashes myself. After reviewing the Security and password encryption code, I would recommend against doing that. SilverStripe uses salted SHA1 encryption which is no fun to try and create yourself. Also you'd have to update multiple tables to get the password changed. Luckily the SS Core team has included multiple features for accomplishing this. The options below assume you have access to your webserver to use some PHP code. Continue reading...
  • TutorialsCreate a front end theme switcher


    So you wanna make a demo site for your customers to show all your template skills in one site. A simple theme switcher can come in handy. It's quite easy to implement this. 

    First add two new functions to your Page_Controller class:

    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...
  • TutorialsAutofill MetaDescription and MetaKeywords on page save


    Most of my customers don't want to add meta info manually, so I add an onBeforeWrite() function to update the Meta Description field and count the keyword density of the content with a separate function and add these keywords to the Meta Keywords fields when a page is saved.

    In my humble SEO opinion every page needs an unique Meta Description. Keywords seems to be less important for search engines, but why not add them automatically anyway! The function counts how many times each word exist in the Content, order the words by occurrence and glues the words to a comma separated string. In this function only words with more then 4 characters are counted, but you can adjust that if you like.

    Continue reading...
  • TutorialsCustomising the WYSYWIG editor (TinyMCE)


    The  default install of SilverStripe contains an array of buttons for the TinyMCE HTML editor. However usually your client will need some extra functionality or you may want to keep things simple for them by removing some of the buttons. As of SilverStripe 2.3.2 this is very easy and can be achieved by adding some code to the _config.php file.

    Continue reading...
  • SnippetsManipulating every Nth item in a <% control %> loop


    Often you will want to manipulate every nth item inside a <% control %> loop. For example say you had a gallery and you wanted every 3rd image to start on a new line, you need to be able to test each item from the template to see if it is divisible by 3 and should therefore have the clear CSS class added to it.

    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...
  • SnippetsRemoving an Item From the Main CMS Menu


    If you want to remove an item from the CMSTopMenu without making it inaccessible you can add this line to your _config.php file:

    Continue reading...
  • TutorialsCreating Previous and Next Buttons on a page


    When you have a number of pages which follow on from one another you may find that asking a user to return to an index or select the next item from a side menu each time they want to progress is cumbersome. In this situation having previous and next buttons at the bottom of a page becomes very useful. In this snippet we'll add these buttons and also a counter to show the current page we are on and the total number of pages.

    Continue reading...
  • SnippetsUsing canCreate(), canEdit(), canDelete() and canPublish() to manage page type permissions


    Often you will want to control which users can create, edit, delete and publish certain page types. For example you may only want high level users to be able to create ContactPage page types, or prevent low level users from deleting HomePage page types. This can easily be achieved by adding these functions to the page type model (usually just before getCMSFields()). Then within the function you can define conditionals which decide whether to return true or false.

    Continue reading...
  • SnippetsChanging the CMS Help Link


    Usually you can change the CMS menu settings from your site configuration, but the "Help" link is hard-coded to allow for translations. This snippet, placed in your site configuration file will override the "Help" link with a link back to your site:

    CMSMenu::add_link('Help', 'Home', Director::baseUrl());
    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...
  • SnippetsAdding a Thumbnail to a DataObjectManager



    This snippet lets you add a thumbnail to items in UncleCheese's Data Object Manager module or a regular Complex Table field. All you need to do is create a function that returns a thumbnail and refer to this function in your DOM or CTF definition.

    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