Archive for March, 2009

Remove the SilverStripe generator meta tag

Oh dear, SilverStripe 2.3.1+ now has an updated meta tag function that has a “generator” meta tag which includes detailed version numbers of the CMS. Eg for version 2.3.1, it has the text: “SilverStripe 2.3.1 – http://www.silverstripe.com”. Take a look here as to why I think this is a bad idea.

This is a real pity, and not something I want to have in a production website. SilverStripe is a great CMS and development framework and deserves praise (as does the web development company behind it, SilverStripe), but not right down to the release number!

Removing the generator tag is pretty straightforward:

  1. Open the Page.ss for your theme. Eg for blackcandy, open /themes/blackcandy/templates/Page.ss
  2. Remove this function call: $MetaTags(false) (could be $MetaTags(true) either)
  3. This prevents the generator tag from being output, but it stops a few other meta tags too, so I suggest you add the following to your Page.ss in the <head> section:
    <title><% if MetaTitle %>$MetaTitle <% else %>$Title <% end_if %>- MyWebSiteName</title>
    <% if MetaKeywords %><meta name="keywords" http-equiv="keywords" content="$MetaKeywords" /><% end_if %>
    <% if MetaDescription %><meta name="description" http-equiv="description" content="$MetaDescription" /><% end_if %>
    <meta name="generator" http-equiv="generator" content="SilverStripe - http://www.silverstripe.com" />
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Language" content="en"/>

  5. Save your file and upload if necessary. Once you flush the cache, your should see the changes

Now you might notice that I did slightly more than just meta tags there: I also updated the <title> tag. The $MetaTags function call I removed can output a title tag if $MetaTags(true) rather than false is set and you have a meta title set for your page in addition to the standard title.

This is a good idea for some pages. For example, a page on a site I was recently working on was called “Home”. This was fine for the navigation label and actual on page title, but “Home – MyWebsiteName” does not look good for a window title or in google search results, so we used the meta title to set something which only appears in the meta data and not on the actual page, which was more descriptive and useful.

You might also notice I did not completely remove the generator tag. Well I do want to show my support for SilverStripe so in this particular instance I have just removed any mention of version numbers. At least you now have control over this text.

Some caveats though: my code above replaces what the MetaTags function currently does, but this may change in future so that were additional functionality added to the function, you might be missing out. It also gathers data such as the language and content-type automatically which you need to set manually in my code (if you need to change it).

I will blog again on the MetaTags function if it does change. A perfect reason for subscribing to my RSS feed!

Comments (5)

What a difference a host makes

Over the past few months I have been struggling to get a website I manage onto a level footing as the site’s traffic began to reach over 750k page impressions per month. The VPS server it was on, despite adding additional cpu and RAM resources to it, continued to struggle – slow page load times, and Apache web server crashes were becoming commonplace.

My initial strategy was to move the site to a Media Temple Grid-Service hosting account. I won’t bore you with the details, but the Grid service has lots of space and bandwidth. Rather than running your site on one server, your site has computing resources available across the grid.

Unfortunately, each account has a limit on the amount of computing power it can use, measured in Grid Performance Units (GPU), and the site looked likely to require 5 or 10 times the amount of GPU’s that are included, and this overage would have run into several hundred dollars of additional charges a month. Not feasible.

The other disappointment was that although the hosting platform had become stable with the move to Media Temple, page load times were still disappointingly slow. This wasn’t a real surprise though as I had noticed this with other Media Temple hosted sites.

So off I went to find another hosting alternative. During my research I came across a crowd called SimpleHelix. I was little sceptical from their site as it looks ahem, rather similar to Media Temple’s, particularly the hosting plan names. Some research on blogs and forums gave mixed, but overall positive reviews, so I decided to give it a whirl. I was particularly interested in it’s technology which speeds up web applications.

A month in, and no complaints. Traffic is still growing, but page load times are much faster, and I have experienced no down time or other support issues.

It is not exactly scientific, but looking at the Google Webmaster stats for the web crawler page load time, I can see that pages have been loading much faster since the change in hosts.

Google Crawl Stats

Now actual page load times will not be as fast as they are for the Google web crawler, but I am sure this does give a sound indicator that page load times have decreased significantly since changing over to SimpleHelix. 

So, not as much disk space or bells and whistles as Media Temple, but excellent performance on a $20/month hosting package for a site serving 750,000 pages a month. Well worth it.

Comments

Trying ModelAdmin on for size

I have lately been doing quite a bit of work using the SilverStripe CMS, which also has a built in development framework, Sapphire. This is the open source child of SilverStripe, a local company here in Wellington.

Version 2.3.0 of SilverStripe comes with a stable version of ModelAdmin, a really handy new tool I have been playing with in the CVS version prior to release. You can see a video of Ingo Schommer from SilverStripe giving an overview of ModelAdmin here. He also has the bones of the presentation up on Slideshare which isn’t as long but you don’t get to have Ingo’s germanic voice caress your ears.

Issues:

HTMLText fields

Modeladmin does not seem to like HTMLText dataobject fields at the moment and their corresponding form field types, HtmlEditorField. In my local WAMP this causes an page to pretened to load for eternity (though I gave up after about 90 secs so cannot fully confirm the eternity thing…).

I don’t see this as a major issue: html fields are best suited to the Site Content tab where all that stuff currently takes place anyway. There seems to be a bug report in for this issue anyway.

Scaffolding

ModelAdmin makes it super easy to give your data a CRUD (Create, Read, Update Delete – thanks Ingo!) interface.  If you have a dataobject with defined relationships (has_one, has_many or many_many), ModelAdmin will create these as drop down lists in your create/edit forms right off the bat.

This is super but right away I noticed a problem: these drop down lists for component dataobjects have no sorting on them. Thus my list of 2,500 New Zealand towns was not in alphabetical order. Far from ideal.

You can work around this by defining your own form via a getCMSFields function for the dataobject.  This allows you to populate your drop down fields via DataObject::get, allowing you a much greater level of control. 

Tip 1: make sure you define it as a new fieldset: $fields = new FieldSet();
Tip 2: use fields->push: $fields->push(new DropdownField(‘MyDataID’,'My Data’,$MyArray->toDropDownMap(‘ID’, ‘Name’)));
Tip 3: See I used  MyDataID as the field name where the field is called MyData. This had me confused for a bit as ModelAdmin was not capturing the input when I was calling the field MyData.

Assuming you avoid the pitfalls I made above, you can create a dataobject, set it up in ModelAdmin, and in 5mins have a back end administration area for your new data object. Fantastic!

Quite often when I encounter these types of “one size fits all” dataobject management tools, they always lack just enough to put you off using them, but I think ModelAdmin passes with flying colours. It is already being tried out in two websites under development.

Comments (1)