SSbits - Home page
Site by Carbon Crayon
Submit a Post >
  • TutorialsDataObjects as Pages - Part 1: Keeping it Simple

    78

    SSBdoaspagesp1

    In this two part tutorial, I am going to show you how to display DataObjects as if they were pages. This is often very useful for times when you have lots of items that don't warrant full site tree objects, but do need to be displayed on their own on the site. In this first part displaying Staff Members we are going to keep it simple, using a Data Object Manager to manage our Staff Members and referring to their ID in the URL. Later in part 2, we will see how to use ModelAdmin to manage a Search Engine friendly product catalogue.

    Continue reading...
  • TutorialsDataObject as Pages: The Module

    78

    SSBdataobjectsaspagesmodule

    It's been a while since we published the DataObject as Pages series of tutorials, which have proved to be particularly popular. At Aab Web we use those techniques regularly as a way to allow our clients to mange large amounts of flat content or content that is distributed in multiple places throughout a site. Although the final implementations in each project are often varied and bespoke, they all start with the basics outlined in those tutorials, so it made sense for us to build a starting point to work from (and include some more complex features at the same time). That starting point is this module, catchily entitled: DataObject as Pages.

    Continue reading...
  • TutorialsDataObjects as Pages - Part 2: Using Model Admin and URL Segments to create a product catalogue

    90

    SSBdoaspagesp2

    We now know the basics of using DataObjects as Pages from Part 1 of this tutorial. In part 2, we are now going to look at taking this further and creating a basic product catalogue with products that are DataObjects managed via the ModelAdmin interface. This tutorial will also serve as an introduction to ModelAdmin it self, which is an extremely powerful CRUD (Create, Read, Update, Delete) manager for any type of DataObject, whether used as pages or not.

    Continue reading...
  • SnippetsA _config.php Cheatsheet

    22

    SSBconfigcheatsheet

    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

    23

    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

    11

    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...
  • SnippetsGetting items from a has_many or many_many relation

    5

    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...
  • TutorialsPaginating a filtered DataObjectSet

    13

    If you have ever tried to paginate a DataObjectSet that has been customised since fetching it from the database you will have descovered that it simply doesn't work. This short tutorial provides some great code to resolve this problem and paginate to your hearts content!

    Continue reading...
  • TutorialsAdd flexible MetaTags control to Pages

    2

    When you display DataObjects as if they are a single Page or use a Page Action to display a different view of the same Page, by default your MetaTags are the same as the tags you entered in the CMS.

    One way to change the MetaTags dynamicly is to add a lot of template controls to display different MetaTags for each view, but you can get a lot more flexibility by overriding the SiteTree MetaTags function in your Page_Controller.

    Continue reading...
  • TutorialsAdd a duplicate button to Model Admin

    15

    SSBmodeladminduplicate

    Often you will want to add some extra features to your Model Admin interface. Luckily it's pretty straightforward when you know how! In this tutorial we are going to add a simple 'Duplicate' button for our managed Model.

    Continue reading...
  • TutorialsCreating and deleting dataobjects from the front end

    41

    postproposal3

    One of my clients wanted a clear interface from which he could easily attach downloadable files to some pages of his site. Instead of using modelAdmin and granting him an access to Silverstripe admin panel, I chose to create a front-end page showing a simple upload form, a list of the files previously uploaded to the server, and a delete button for each of them.

    Continue reading...
  • SnippetsPreventing malicious SQL injections

    3

    SSBsecuringyoursite

    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...
  • TutorialsDynamically Generating Dropdown Lists

    9

    This post title may look familiar, but it has in fact been completely re-written with lots of new code! When using dropdown menus, you will often want to dynamically generate the options, usually to a list of DataObjects or Pages for the user to choose from. This tutorial explores the options at your disposal when it comes to creating dynamic dropdowns in the SilverStripe.

    Continue reading...
  • TutorialsSorting on a related DataObject in ModelAdmin

    1

    Sometimes, in ModelAdmin, we want to be able to have a different default sort.

    Specifically, like in cases where a has_one is the preferred sorting. For example, we have a warehouse. In our DataObjects, we have the object "Lanes", has_many Products. And we have Products, has_one "Lanes". When we're browsing our Products in the admin, we want to have them default sorted by their Lane, not their name.

    Just saying default_sort = 'Lanes'; sadly does not do the job. It'll give you reddish-screens and stuff. Which is not what we like.

    Here's a (quite simple actually) solution.

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

    3

    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...

Advertisement

Site of the Month

Find SSbits on

Top Contributers

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

View full leaderboard


Advertisement