21475 Posts in 5781 Topics by 2620 members
| Go to End | Next > | |
| Author | Topic: | 4128 Views |
-
ModelAdmin $summary_fields image width

4 April 2009 at 1:46pm
I am setting up a data management framework using ModelAdmin in 2.3.1.
I would like to display a small image in the summary fields for data objects so users have a quick reference to a piece of artwork to select. Is there a way to use SetWidth() in the $summary_fields for the CMS?
Thanks all, Y
-
Re: ModelAdmin $summary_fields image width

5 April 2009 at 9:04pm
$summary_fields can refer to a method of your dataobject, for example 'ImageForSummaryField' where this method returns the resized image.
-
Re: ModelAdmin $summary_fields image width

5 April 2009 at 11:04pm
Thanks very much for this. Would you mind providing example code to illustrate?
-
Re: ModelAdmin $summary_fields image width

13 April 2009 at 6:44pm
Hey,
seems like this post contains the answer:
http://www.silverstripe.org/general-questions/show/257794
I'm pretty new to Silverstripe as well and have not yet given this solution a try, but as far I understand, you should add a static column "Thumbnail" (next question: which type?) and then add a public function getThumbnail() which than returns the image.
Please post whether this worked.Greets,
Henning
-
Re: ModelAdmin $summary_fields image width

26 August 2009 at 1:48am
Hi, i can't get it working. How can i refer to the method?
static $summary_fields = array(
????
); -
Re: ModelAdmin $summary_fields image width

26 August 2009 at 9:52am
eg (untested):
static $db = array(
'Name' => 'Varchar',
);static $has_one = array(
'Image' => 'Image'
);static $summary_fields = array(
'Name',
'SmallImageThumbnail'
);function SmallImageThumbail() {
return $this->Image()->SetHeight(40);
} -
Re: ModelAdmin $summary_fields image width

28 September 2009 at 11:12pm
I tried above example, however i get the following error message.
[User Error] Uncaught Exception: Unable to traverse to related object field [SmallImageThumbnail] on [Ticker]
No matter what I try, i can't seem to get it to work.
I tried naming the function getSmallImageThumbnail, same error.
I tried using TickerImage.CMSThumbnail, same error only with TickerImage.CMSThumbnail instead of SmallImageThumbnail.<?php
class Ticker extends DataObject {
static $db = array(
'LinkType' => 'Enum(\'Internal,File,External\',\'Internal\')',
'LinkTarget' => 'Enum(\'_self,_blank\', \'_blank\')',
'ExternalURL' => 'Varchar(255)'
);static $has_one = array(
'TickerImage' => 'Image',
'TickerFile' => 'File',
'LinkTo' => 'SiteTree'
);static $summary_fields = array(
'SmallImageThumbnail',
'LinkType'
);public function SmallImageThumbnail() {
return $this->TickerImage()->setHeight(50);
}
}
?> -
Re: ModelAdmin $summary_fields image width

29 September 2009 at 2:40am
I wanted to do something very similar a few months ago and found this 'tutorial' very useful:
http://www.ssbits.com/adding-a-thumbnail-to-a-dataobjectmanager-or-complex-table-field/
| 4128 Views | ||
| Go to Top | Next > |





