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.

Data Model Questions /

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

[SOLVED] Image thumbnail in list action (DataObject / ModelAdmin)


Go to End


8 Posts   4550 Views

Avatar
Mad_Clog

Community Member, 78 Posts

2 July 2009 at 1:12am

Edited: 05/10/2009 11:14pm

Hi,

I was wondering if it's possible to display a thumbnail of an image in the list overview in a DataObject managed by ModelAdmin.
I've tried casting it but so far without luck.

Any help is appreciated, cheers.

Geert

Avatar
Mad_Clog

Community Member, 78 Posts

6 July 2009 at 10:09pm

Anyone!?

*bump*

Avatar
AdamJ

Community Member, 145 Posts

6 July 2009 at 11:44pm

Avatar
Mad_Clog

Community Member, 78 Posts

5 October 2009 at 11:13pm

simon_w on IRC helped me solve this issue
just add <fieldName>.CMSThumbnail.Tag to $summary_fields and you're set to go.

	static $has_one = array(
		'TickerImage' => 'Image'
	);
	static $summary_fields = array(
		'TickerImage.CMSThumbnail.Tag'
	);

Avatar
bartvanirsel

Community Member, 96 Posts

9 February 2011 at 4:14am

thanks for this post! helped me out!

Avatar
jamesg

Community Member, 8 Posts

11 August 2011 at 4:58pm

I just wanted to add to this in case it will help someone else.

Today I was doing something similar I had the following DataObject:

class Competition extends DataObject
{
	
	public static $db = array(
		'Name'  => 'Varchar(255)',
		'Start' => 'SSDatetime',
		'End'   => 'SSDatetime'
	);
	
	public static $summary_fields = array(
		'Name',
		'Duration'
	);
	
	public function Duration()
	{
		return $this->dbObject('Start')->Full() . ' - ' . $this->dbObject('End')->Full();
	}
	
}

The problem was I would get the following error message when visiting the model admin in the CMS:

Error: "Uncaught Exception: Unable to traverse to related object field [Duration] on [Competition]" at line 2492 of /sapphire/core/model/DataObject.php

Turns out to stop this from happening all you need to do is define the searchable_fields, like so:

public static $searchable_fields = array(
	'Name'
);

Hopefully this will help someone else in my situation :)

Avatar
JonoM

Community Member, 130 Posts

2 November 2011 at 10:42pm

Thank god for you James! That was driving me crazy - I had got a method call to work in $summary_fields before and I couldn't work out why the hell it wouldn't work this time. Seems like a bug to me so I reported it at http://open.silverstripe.org/ticket/6761

Avatar
BenWu

Community Member, 97 Posts

13 June 2012 at 2:22am

JonoM

It looks like this bug you reported is still not resolved yet... I am using 2.4.7