Using SilverStripe CMS

March 24, 2010 at 3:09 PM
filed under cms, silverstripe, web development

I’ve just finished my first website using SilverStripe – a free Content Management System (CMS) built with PHP.
I used Google a lot to find answers to questions I had; this post is a list of these questions and answers.

SilverStripe-Logo-with-words

My Server Environment

Server: Windows Server 2003 R2
WAMP: The Uniform Server – (with the latest Apache, MySQL, PHP)
SilverStripe Version: 2.3.7

Things I had to Google

Change the breadcrumb separator

This arrow symbol (») is used as the default breadcrumb separator.
You can change this by editing /sapphire/core/model/SiteTree.php

Search SiteTree.php for the variable named $breadcrumbs_delimeter.
Update the breadcrumb separator to what you want.

/**
* Delimit breadcrumb-links generated by BreadCrumbs()
*
* @var string
*/
public static $breadcrumbs_delimiter = " » ";

editor.css stylesheet not being used in HTML editor

I came across a bug where SilverStripe would not use my editor stylesheet in the HTML editor.
This can by fixed by adding the following line to mysite/_config.php

HtmlEditorConfig::get('cms')->setOption('content_css', 'cms/css/editor.css, mysite/css/editor.css');

Alter the third parameter of the setOption method to the path where your editor.css file is located.

Targeting Mac Firefox

The following code with some minor tweaks can be used to target any browser / OS.
I’m adding it here to show how easy it is to create variables for use in your templates.

To add a variable that can be used in your templates edit /mysite/code/Page.php

Add this function:

function isMacFF() {
    // Get the user agent
    $userAgent = $_SERVER['HTTP_USER_AGENT'];

    $browser  = "Firefox";
    $os = "Mac OS X";
    $version = ""; // You could add version or anything else you are looking for here

    // Check the string is in the user agent
    $browserTest = strpos($userAgent, $browser);
    $osTest = strpos($userAgent, $os);

    // If both conditions are true we know it is Firefox for Mac
    // Add more conditions if you are testing for anything else
    if ($browserTest == true && $osTest == true)  {
        return TRUE;
    } else {
        return FALSE;
    }
}

Thanks to George Ornbo for this OS/browser targeting PHP code.

In your main page template add this:

<% if isMacFF %>

<% end_if %>

Changing /themes/apprenticeshipsfirst/css/mac_ff.css to the path of your Mac+FF CSS file.

I would have used <% require themedCSS(mac_ff) %> to add the stylesheet but I found it adds the Mac+FF stylesheet regardless of the conditional statement.

Creating a Dynamic Sitemap

Creating a dynamic sitemap is simple with SilverStripe.
Follow the instruction here: http://doc.silverstripe.org/doku.php?id=tutorial:site-map

Admin area breaks

While using SilverStripe I ran into an error where duplicating a webform page resulted in the admin area breaking. When the error occured a JavaScript alert popped up informing me something went wrong.
After this I was unable to get to the admin area.

To fix this:
Put site into dev mode.
You do this by adding the following line of code to /saphire/_config.php :

Director::set_environment_type("dev");

Comment out the line in the offending file – this is listed in the error message once the site is put into dev mode. In my case I commented out a line that throws an exception – in the Object.php file.

//throw new Exception("Object->__call(): the method '$method' does not exist on '$this->class'");

Now rebuild your SilverStripe database by visiting http://yoursite.com/dev/build.
Don’t worry, this rebuild won’t delete any of your site’s content. After the rebuild visit your admin area which you should be able to get into again.
Complete the action you were trying to do before you received the error then restore this line by removing your comment.

404 page not being used

In my SilverStripe installation a 404 page existed but when I typed in a URL that didn’t exist it would not use this 404 page.
It instead showed a SilverStripe themed error page saying:

Website Error Not Found
The website server has not been able to respond to your request.

After Googling the problem I found you have to publish this default 404 page before it will be used by SilverStripe.
To publish, select your ‘Page Not Found’ page and click ‘Save and Publish’.
Do a site flush by adding ?flush=all to the URL and it will now use this custom 404 page.

Website not displayed using The Uniform Server

I chose The Uniform Server as my all-in-one WAMP solution.
I chose this because it installs with strict security settings enabled and can be used on a production server.
When using it for the first time I ran into the problem where when I logged out of the Remote Desktop Connection for my production server it would stop serving my website.
I found out The Uniform Server can be run as a standard program – running via logged in user – or it can be run as a service.
When using this on a production server you want to run this as a service. To run as a service follow these directions: http://wiki.uniformserver.com/index.php/5.0-Nano:_Install_and_Run#Run_as_a_Service_.28Vista_and_W7.29

Useful Links

Conclusion

SilverStripe is easy to install, use and extend.
SilverStripe comes with all the features I was looking for:

The functionality it lacked I was able to add with a module.

I’ve used Joomla and Drupal CMS in the past and found SilverStripe much easier and quicker to build a website with.
SilverStripe templates are great, using normal HTML with custom tags.
The editing interface is simple and easy to use. The admin interface is more intuitive than any other CMS I’ve used.

I recommend SilverStripe to anyone looking for a good, free CMS.

Thanks to Reece for getting me onto SilverStripe.

Share this:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • FriendFeed
  • HackerNews
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Tumblr
  • Twitter
  • Ping.fm

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

5 comments

RSS / trackback

respond

  1. Mark Lands

    on April 2, 2010 at 1:33 AM

    Good post mate, way over my head but im sure it will be a good help for someone.

  2. Paul Sauve

    on July 22, 2010 at 5:55 PM

    Hi Nathan,

    I was wondering if you could point me in the right direction?

    Could you tell me where I can find how to install SilverStripe on Uniserv?

    I have managed to create iterations (using 'localhost') of Joomla, WordPress & Wiki. But it seems that no two installs are exactly the same. For example, Joomla installs on a running version of Uniserver, but WordPress is installed BEFORE running the version of uniserver.

    Thanks,

    Paul S.

  3. n8kowald

    on July 22, 2010 at 7:41 PM

    Hi Paul,

    I installed my SilverStripe site on a development server using WAMPServer – http://www.wampserver.com/en/.
    When my site was ready to go live I moved the files and tables over to my live server, running Uniform Server.

    It's a pity the Uniform Server wiki – installation category doesn't include an 'Installing SilverStripe' guide: http://wiki.uniformserver.com/index.php/Category:...

    Uniform Server needs to be running when you install it. During installation you should use localhost and the mysql user details you set up – or defaults if not changed (user: root, password: root – I think).

    Installation should be similar to (steps 7-12) on this: http://doc.silverstripe.org/installation-on-windo... – though in step 8 you need to place SilverStripe into Uniform Server's root folder – www.

    Googling for a SilverStripe installation guide for Uniform Server I came across this which might be useful if you run into this problem: http://www.silverstripe.org/archive/show/2708#pos...

    Sorry I couldn't be more help or point you to a SilverStripe installation guide specific to Uniform Server. If you do find one please tell me so I can add it to my blog post.

    Nathan

  4. Paul Sauve

    on July 23, 2010 at 12:08 AM

    Thanks for the quick response Nathan – I'll give it a shot this weekend & let you know how it works out.

    I'll try following the installation for Joomla, since Joomla installs on a running version of Uniserver.

    If it works, I'll post it here (detailled installation & on the Uniform Server wiki.

    Paul

  5. n8kowald

    on July 23, 2010 at 9:47 AM

    Thanks Paul, hopefully it will install without too much messing about.