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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Modifying SummaryFields as they are displayed


Go to End


11 Posts   7005 Views

Avatar
timwjohn

Community Member, 98 Posts

13 July 2010 at 8:44pm

Nice one martimiz! This will definitely come in handy.

I was in fact referring to ModelAdmin in this instance. Any pointers?

Avatar
martimiz

Forum Moderator, 1391 Posts

13 July 2010 at 9:32pm

Yeah, well.. In ModelAdmin, FieldFormatting for the tlf is set in the getResultsTable(..) method in the ModelAdmin_CollectionController class, where it creates the clickable link around the field value. So this would be a very dirty hack (just to hint):

ModelAdmin.php line 721 - replace:

function getResultsTable($searchCriteria) {
  ...
  $tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));
  ...
}

By:

function getResultsTable($searchCriteria) {
 ...
 $arrFormatting = array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url));

 $arrFormatting['Date'] = str_replace('$value', '$NiceDate', $arrFormatting['Date']);

 $tlf->setFieldFormatting($arrFormatting);
 ...
}

Doing it the proper way would require some major extending of the ModelAdmin classes, I guess, and defining some sort of $formatted_fields static property, equivalent to $summary fields, unless I'm missing something obvious. It is doable, but would be a nice new feature for the ModelAdmin class maybe :-)

Avatar
timwjohn

Community Member, 98 Posts

15 July 2010 at 9:39pm

Ok, thank you very much for that Martimiz.

As much as I dislike dirty hacks, if this is what the client wants it's what they get!

I agree it would be a good feature for ModelAdmin.

Go to Top