Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Modifying SummaryFields as they are displayed

Go to End

11 Posts   3658 Views


5 June 2010 at 1:30am (Last edited: 5 June 2010 1:31am), Community Member, 98 Posts

Is it possible to modify the display of the SummaryFields as they appear in a list?

Specifically, I've included the LastEdited field in my custom DataObject's SummaryFields, but would like to display it in a friendlier format while still being able to column sort chronologically...


7 June 2010 at 8:17am Community Member, 243 Posts

Its pretty simple to customise how the summary fields look for the user.

class myObject extends DataObject {

static $db = array(
'Title' => 'Varchar',
'Date' => 'SSDatetime'

static $summary_fields = array(
'Title' => 'Title',
'NiceDate' => 'Date

function getNiceDate() {
return $this->dbObject('Date')->Nice();


This means you can still sort by date, but then show a 'nice' date in the summary fields. Hope that is what you were looking for.


9 June 2010 at 9:15pm Community Member, 98 Posts

Thanks for the reply Pigeon.

However, this method wouldn't allow me to sort the NiceDate column. It would just appear unsortable. Only direct database fields are sortable, and NiceDate is just the returned value of a getter. Even if I were to write a nicer version of the date to a database field and sort that, it would be sorted alphanumerically rather than chronologically.

What I was getting at was the possibility of having a field that is altered for display purposes, but remains a sortable date field under the bonnet. Is this possible?


10 June 2010 at 10:26am Community Member, 243 Posts

Do you mean sortable by the user in the CMS side? rather than how it is pulled out of the DB in the class?


10 June 2010 at 8:54pm Community Member, 98 Posts

Yeah, that's what I mean.

Just wondering if there's a feature of SilverStripe that can do this...


2 July 2010 at 11:01pm Community Member, 6 Posts

Did you find any workaround? I'm facing the same problem.


5 July 2010 at 2:44am Community Member, 98 Posts

No I didn't I'm afraid. Just displayed the raw dates. It's probably a good idea to put it in as a feature request. I'll do that when I get the chance.


12 July 2010 at 1:41am Forum Moderator, 1091 Posts

On TableListField (and all classes derived from it) you can influence the way fielddata are displayed in the list by using the setFieldFormatting() method. It receives an array('field name' => 'formatting string'). This will leave the way the field is sorted intact, based on the underlying (db)field value (at least that's what I found).

More info here You can use the $NiceDate from the post above in the formatting string (instead of $value).

If you're referring to ModelAdmin: that's far more complex, although it could be done (without the dirty hack, that is :-) )


Go to Top