Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » How to add File->Filename to List View of Page/Resources

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1138 Views
  • tilluigi
    Avatar
    Community Member
    9 Posts

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

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: How to add File->Filename to List View of Page/Resources Link to this post

    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.

  • tilluigi
    Avatar
    Community Member
    9 Posts

    Re: How to add File->Filename to List View of Page/Resources Link to this post

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

    1138 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.