Snippets - Little bits of code to make you happy
SnippetsA _config.php Cheatsheet
2 July 2010 | | | Supports v2.4Tweet
If your anything like me, you've probably found yourself going through your previous sites looking for that line of code to put in your _config.php file. Well, now you nolonger need to, simply bookmark this page and return to it any time you need to add a line to your config! And if I've missed out anything leave a comment and I'll make sure it gets added :)Continue reading...
SnippetsA Data Object Manager Cheatsheet
6 October 2010 | |Tweet
We all love the DataObject Manager (DOM, not to be confused with the Document Object Model) as well as its creator UncleCheese of LeftAndMain.com. However one thing which has always frustrated me is having to look back through my code or even worse having to search the forums to find that function to set the upload folder, or create a filter for my DOM. So here within this page, lies a comprehensive list of all the things you can do with your DOM and File/ImageDOM. Viva la DOM!Continue reading...
SnippetsOptimizing Complex Models
4 November 2010 | | | Supports v2.4, v2.3Tweet
The SilverStripe ORM engine (Sapphire) makes working with your database a breeze, but that simplicity comes at a cost. Each database query contributes to slower page load times and a complicated data structure can create significant performance issues.
Here are a number of strategies that can be employed to improve your website query performance:Continue reading...
7 October 2010 | | | Supports v2.4, v2.3Tweet
Have you ever found yourself using DataObject::get() to fetch objects in a has_many so that you can filter/sort them easily?
Well as it happens there is no need to do this thanks to a totally undocumented bit of code!Continue reading...
4 December 2010 | | | Supports v2.4, v2.3Tweet
As you will most likely already know, reducing the number of HTTP requests that your site makes can have a significant effect on loading times. However, usually it's not practical to combine all your files into a single one for reasons of maintainability. This is where SilverStripe steps in and provides an elegant, automated solution to this common 'requirement' (lol, get it?).Continue reading...
2 April 2012 | | | Supports v2.4, v2.3Tweet
Here are some handy dynamic bookmarklets for your browser for one click access to things like rebuilding the database, flushing the cache and accessing the CMS!Continue reading...
31 May 2010 | | | Supports v2.4, v2.3Tweet
The Member system that comes with SilverStripe offers substantial control over your site's authentication capabilities. It often requires the developer to build out or extend most common functionality to websites. This is great in that you are never "stuck" with the out-of-the-box offerings, but as any SS dev knows you end up with a little bag of Member tricks that gets used across many projects. Presented here is one that I use often.Continue reading...
15 April 2010 | | | Supports v2.4, v2.3Tweet
Often when doing development work on a website - and particularly the templates - it can be a pain having to remember to add ?flush to the end of the URL to make sure all of your changes have come through. I'm sure that all of us have had that "d'oh" moment when we have spent too much time wondering why our changes weren't working, only to find a simple flush fixed it.Continue reading...
15 October 2010 | | | Supports v2.4Tweet
2.4 has introduced the SiteConfig, which by default allows the user to switch themes - if they exist.
It's incredibly useful to have this functionality built-in now, but for those that only have one theme for a site, it's a bit of unnecessary clutter. Here is how to remove it by using a decoratorContinue reading...
27 September 2011 | | | Supports v2.4Tweet
This is a little snipped i've been using to redirect a custom page to it's first child. It extends the init method of the Controller. This has proven useful in cases where the client wants to re-sort the child pages and doesn't want to mess around the configuration of a redirector page.Continue reading...
22 March 2011 | | | Supports v2.4Tweet
If you have ever had to edit content on a SilverStripe site with lots of pages, you will have noticed how furstrating it is to have to keep scrolling back up the tree panel to create a page or enable drag and drop re-ordering. Well, here is a handy bit of CSS you can add to keep the tools static, even as you scroll down the tree.Continue reading...
12 July 2011 | | | Supports v2.4Tweet
Most search results I have seen with Silverstripe just return the Summary of the page or the FirstSentence. I have knocked up a quick way to show a sentence from the page that contains the search term and even highlights it for you.Continue reading...
11 September 2011 | | | Supports v2.4, v2.3Tweet
The problem I was trying to solve was for a dropdown select box to toggle fields in the form, depending on whether a link is internal or external to the site.Continue reading...
12 March 2010 | | | Supports v2.4, v2.3Tweet
PHP has a very shallow learning curve, it's free and anyone can have a go at making a website by following a few tutorials and implementing their experience with other languages. However, coding for the web can be a risky business, especially with dynamic websites that take some kind of user (or external) input and use that to get data from a database.Continue reading...
SnippetsAdding Gravatars to your site
8 October 2010 | | | Supports v2.4, v2.3Tweet
Gravatar is a great service that allows you to pull in members profile photos directly from their Gravatar accounts. It's used right here on SSbits and it also part of the Forum module. It's also incredibly easy to integrate into your site!Continue reading...