Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » HasManyFileManager: New CMS module/extension. Testers/review needed

Our old forums are still available as a read-only archive.

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

Page: 1 2 3 4 5 6 7 8
Go to End
Author Topic: 104039 Views
  • banal
    Avatar
    Community Member
    901 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Oh wow. So many views on that Topic...

    Somehow i missed the last few replies from you guys. Sorry! I was totally busy with finishing my diploma. I hope i'll be able to further improve the HasManyFileManager in the near future. Maybe turn it into a real Module for SilverStripe too. If possible i'd like to put it into the silverstripe repository, instead of my own svn repo.

    @UncleCheese:
    Adding more fields to a file shouldn't be a Problem (did that already). You'll have to create a custom DataObjectDecorator for the File class. Here's a simple example

    <?php
    class MyFile extends DataObjectDecorator
    {
       public function extraDBFields() {
          return array(
             'db' => array(
                'someFlag' => 'Boolean'
             )
          );
       }

       public function getCMSFields(){
          return new FieldSet(
             new TextField('Title', _t('AssetAdmin.TITLE'), $this->owner->Title),
             new DropdownField('someFlag', 'Has Flag?', array(1=> 'Yes', 0 => 'No'), $this->owner->someFlag)
          );
       }
    }

    This decorator adds a new Boolean-Field "someFlag" to the database and allows editing using a DropdownField. You could extend this to any kind of input of course, but be careful with field types that require special JavaScript functionality (you'll have to load the JS code in the iframe too. This is supported, but a bit tricky to do).

    To make this whole thing work, you'll have to add another line to your _config.php File:

    DataObject::add_extension('File', 'MyFile');

    I hope that helps. If it doesn't then i probably didn't put my latest sources up for download ;)
    Cheers -- banal

  • UncleCheese
    Avatar
    4085 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Awesome! Thanks for the reply, banal.. I've been so jazzed about this thing ever since I saw it. Definitely keep us posted about progress. There's a lot of interest here!

  • jjeziorski
    Avatar
    Community Member
    11 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    First of all great work. That's what i was looking for.

    However, I have some problems/errors (possibly due to my ignorance).
    There's a snapshot of an error that i get upon installation of module. I have followed your guides and created an ImagePage and also an ImageFile extension of DataObjectDecorator with following code:

    class ImageFile extends DataObjectDecorator
    {
    public function extraDBFields() {
    return array(
    'db' => array(
    'Description' => 'Text'
    )
    );
    }

    public function getCMSFields(){
    return new FieldSet(
    new TextField('Title', _t('AssetAdmin.TITLE'), $this->owner->Title),
    new TextareaField('Description', _t('AssetAdmin.DESCRIPTION'), $this->owner->Description)
    );
    }
    }


    It was also included in module _config.php file

    Problems encountered:

    1. error seen on image - commenting out line 231: "$file->update($data);" stopped triggering an error, though even before all data seemed to save properly.
    2. I don't get any images on published site: used template code from demo
    3. additional data "Description" seem to fail to save.

    Any help will be most welcome
    Thanks,
    Jake

  • Bo_Einzeller
    Avatar
    Community Member
    18 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Hy Banal
    Great work! I already used your filemanager for 2 websites and in this way, i fixed some errors.
    The most of them occured when i tried to implement it in the newest draft-Version of SS.

    So, here's a shortcut what i've fixed:
    - getCMSFields is implemented in the draft-Version so it can't be decorated. I renamed it to getMyCMSFields

    - Cause Form-Handling has Changed in the draft-Version, the director Link should always have the item-ID attached. Otherwise we run in several errors

    - Uploads with the same filename are messed up every second time. So i upload the file directly in its SubFolder:
    $newId = $folder->addUploadToFolder($data['Upload']);

    - Formated Images aren't deleted with the main-Image, so i wrote my own deleteFormattedImages Function.

    I've Attached the whole Code.

    @ jjeziorski:
    I had this Problem with a draft-Version of Silverstripe. I think you can solve it by replace
    Line 231 ($file->update($data);)
    with
    foreach($data as $k => $v) {
    if($v && isset($file->$k)) $file->$k = $v;
    }

    Cheers

  • banal
    Avatar
    Community Member
    901 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    @Bo_Einzeller

    Great! Thanks for looking into it and fixing stuff. I wasn't able to test the filemanager with the CVS Version of SilverStripe as of now.

    It's funny that we stumbled upon the same problems. You mentioned the formatted images and the upload folder problem. I discovered these too while i was developing the module and filed two bugs/requests:
    http://open.silverstripe.com/ticket/2719
    http://open.silverstripe.com/ticket/2712

    Cheers

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    This extension rules... thanks!

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    This extension kicks ass. Subscribing for future discussion.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Hey banal, had a quick browse through the code, solid work!
    Are you interested in hosting your module on svn.silverstripe.com?
    This would mean you get free bugtracking, a more structured release process, and a unified place for your users to look for new versions and cutting-edge development.

    104039 Views
Page: 1 2 3 4 5 6 7 8
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.