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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How to add File->Filename to List View of Page/Resources


Go to End


3 Posts   1891 Views

Avatar
tilluigi

Community Member, 9 Posts

28 October 2009 at 4:51am

I am trying to display the Filename of my FileObject linked to my Page via ResourceObject. In my Page->getCMSFields() I have tried things like:

$manager = new FileDataObjectManager(
	$this, 
	'Resources',
	'Resource',
	'Attachment', 
	array(
		'Name' => 'Name',
		'Attachment()->Filename' => 'Filename'
	), 
	'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
);

But with no luck. Is there a way to achieve this?

Thanks,
Tilluigi

Avatar
UncleCheese

Forum Moderator, 4102 Posts

28 October 2009 at 5:20am

Try:

   array(
      'Name' => 'Name',
      'Attachment.Filename' => 'Filename'
   ),

If that doesn't work, define in your 'Resource' class:

function getFilename()
{
return $this->Attachment()->Filename;
}

and then use

   array(
      'Name' => 'Name',
      'Filename' => 'Filename'
   ),

Also, keep in mind you can use setGridLabelField() in FileDOM to show the filename, too, if you want.

Avatar
tilluigi

Community Member, 9 Posts

28 October 2009 at 5:29am

i love you unclecheese! the first version works like a charm!